Merge branch 'staging' into framework
This commit is contained in:
@@ -253,7 +253,7 @@ define([
|
||||
stopListening(listener);
|
||||
cb();
|
||||
});
|
||||
listener = listenForKeys(close, close);
|
||||
listener = listenForKeys(close, close, ok);
|
||||
var $ok = $(ok).click(close);
|
||||
|
||||
document.body.appendChild(frame);
|
||||
@@ -302,7 +302,7 @@ define([
|
||||
$ok.click();
|
||||
}, function () { // no
|
||||
$cancel.click();
|
||||
});
|
||||
}, input);
|
||||
|
||||
document.body.appendChild(frame);
|
||||
setTimeout(function () {
|
||||
@@ -350,7 +350,7 @@ define([
|
||||
$ok.click();
|
||||
}, function () {
|
||||
$cancel.click();
|
||||
});
|
||||
}, ok);
|
||||
|
||||
document.body.appendChild(frame);
|
||||
setTimeout(function () {
|
||||
|
||||
@@ -2236,6 +2236,46 @@ define([
|
||||
}
|
||||
$iframe.load(w2); //cb);
|
||||
}
|
||||
}).nThen(function (waitFor) {
|
||||
if (sessionStorage.createReadme) {
|
||||
var w = waitFor();
|
||||
require(['/common/cryptget.js'], function (Crypt) {
|
||||
var hash = common.createRandomHash();
|
||||
Crypt.put(hash, Messages.driveReadme, function (e) {
|
||||
if (e) {
|
||||
console.error("Error while creating the default pad:", e);
|
||||
return void w();
|
||||
}
|
||||
var href = '/pad/#' + hash;
|
||||
var data = {
|
||||
href: href,
|
||||
title: Messages.driveReadmeTitle,
|
||||
atime: new Date().toISOString(),
|
||||
ctime: new Date().toISOString()
|
||||
};
|
||||
common.getFO().pushData(data, function (e, id) {
|
||||
if (e) {
|
||||
console.error("Error while creating the default pad:", e);
|
||||
return void w();
|
||||
}
|
||||
common.getFO().add(id);
|
||||
w();
|
||||
});
|
||||
});
|
||||
delete sessionStorage.createReadme;
|
||||
});
|
||||
}
|
||||
}).nThen(function (waitFor) {
|
||||
if (sessionStorage.migrateAnonDrive) {
|
||||
var w = waitFor();
|
||||
require(['/common/mergeDrive.js'], function (Merge) {
|
||||
var hash = localStorage.FS_hash;
|
||||
Merge.anonDriveIntoUser(getStore().getProxy(), hash, function () {
|
||||
delete sessionStorage.migrateAnonDrive;
|
||||
w();
|
||||
});
|
||||
});
|
||||
}
|
||||
}).nThen(function () {
|
||||
updateLocalVersion();
|
||||
common.addTooltips();
|
||||
|
||||
@@ -4,7 +4,7 @@ define([
|
||||
'/bower_components/chainpad-crypto/crypto.js?v=0.1.5',
|
||||
'/bower_components/textpatcher/TextPatcher.amd.js',
|
||||
'/common/userObject.js',
|
||||
'/common/migrate-user-object.js'
|
||||
'/common/migrate-user-object.js',
|
||||
], function ($, Listmap, Crypto, TextPatcher, FO, Migrate) {
|
||||
/*
|
||||
This module uses localStorage, which is synchronous, but exposes an
|
||||
@@ -196,11 +196,11 @@ define([
|
||||
|
||||
Migrate(proxy, Cryptpad);
|
||||
|
||||
//storeObj = proxy;
|
||||
store = initStore(fo, proxy, exp);
|
||||
if (typeof(f) === 'function') {
|
||||
f(void 0, store);
|
||||
}
|
||||
//storeObj = proxy;
|
||||
|
||||
var requestLogin = function () {
|
||||
// log out so that you don't go into an endless loop...
|
||||
|
||||
@@ -83,9 +83,9 @@ define([
|
||||
});
|
||||
};
|
||||
|
||||
exp.anonDriveIntoUser = function (proxy, cb) {
|
||||
exp.anonDriveIntoUser = function (proxyData, fsHash, cb) {
|
||||
// Make sure we have an FS_hash and we don't use it, otherwise just stop the migration and cb
|
||||
if (!localStorage.FS_hash || !Cryptpad.isLoggedIn()) {
|
||||
if (!fsHash || !Cryptpad.isLoggedIn()) {
|
||||
if (typeof(cb) === "function") { return void cb(); }
|
||||
}
|
||||
// Get the content of FS_hash and then merge the objects, remove the migration key and cb
|
||||
@@ -102,13 +102,13 @@ define([
|
||||
return;
|
||||
}
|
||||
if (parsed) {
|
||||
var proxy = proxyData.proxy;
|
||||
var oldFo = FO.init(parsed.drive, {
|
||||
Cryptpad: Cryptpad
|
||||
});
|
||||
var onMigrated = function () {
|
||||
oldFo.fixFiles();
|
||||
var newData = Cryptpad.getStore().getProxy();
|
||||
var newFo = newData.fo;
|
||||
var newFo = proxyData.fo;
|
||||
var oldRecentPads = parsed.drive[newFo.FILES_DATA];
|
||||
var newRecentPads = proxy.drive[newFo.FILES_DATA];
|
||||
var oldFiles = oldFo.getFiles([newFo.FILES_DATA]);
|
||||
@@ -152,7 +152,7 @@ define([
|
||||
if (!proxy.FS_hashes || !Array.isArray(proxy.FS_hashes)) {
|
||||
proxy.FS_hashes = [];
|
||||
}
|
||||
proxy.FS_hashes.push(localStorage.FS_hash);
|
||||
proxy.FS_hashes.push(fsHash);
|
||||
if (typeof(cb) === "function") { cb(); }
|
||||
};
|
||||
oldFo.migrate(onMigrated);
|
||||
@@ -160,7 +160,7 @@ define([
|
||||
}
|
||||
if (typeof(cb) === "function") { cb(); }
|
||||
};
|
||||
Crypt.get(localStorage.FS_hash, todo);
|
||||
Crypt.get(fsHash, todo);
|
||||
};
|
||||
|
||||
return exp;
|
||||
|
||||
@@ -73,7 +73,6 @@ define(['json.sortify'], function (Sortify) {
|
||||
});
|
||||
};
|
||||
|
||||
console.log('here register');
|
||||
sframeChan.on('EV_METADATA_UPDATE', function (ev) {
|
||||
meta = ev;
|
||||
if (ev.priv) {
|
||||
|
||||
@@ -42,6 +42,25 @@ var afterLoaded = function (req) {
|
||||
updated: updated,
|
||||
cache: data.cache
|
||||
};
|
||||
data.localStore = data.localStore || {};
|
||||
var lsUpdated = {};
|
||||
window.cryptpadStore = {
|
||||
get: function (k, cb) {
|
||||
setTimeout(function () { cb(data.localStore[k]); });
|
||||
},
|
||||
getAll: function (cb) {
|
||||
setTimeout(function () {
|
||||
cb(JSON.parse(JSON.stringify(data.localStore)));
|
||||
});
|
||||
},
|
||||
put: function (k, v, cb) {
|
||||
cb = cb || function () { };
|
||||
lsUpdated[k] = v;
|
||||
setTimeout(function () { data.localStore[k] = v; cb(); });
|
||||
},
|
||||
updated: lsUpdated,
|
||||
store: data.localStore
|
||||
};
|
||||
window.cryptpadLanguage = data.language;
|
||||
require(['/common/sframe-boot2.js'], function () { });
|
||||
};
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
define([
|
||||
'jquery',
|
||||
'/api/config',
|
||||
'/common/cryptpad-common.js',
|
||||
'/common/common-util.js',
|
||||
'/common/media-tag.js',
|
||||
'/common/tippy.min.js',
|
||||
'/customize/application_config.js',
|
||||
|
||||
'css!/common/tippy.css',
|
||||
], function ($, Cryptpad, MediaTag, Tippy, AppConfig) {
|
||||
], function ($, Config, Cryptpad, Util, MediaTag, Tippy, AppConfig) {
|
||||
var UI = {};
|
||||
var Messages = Cryptpad.Messages;
|
||||
|
||||
@@ -291,6 +293,103 @@ define([
|
||||
}
|
||||
};
|
||||
|
||||
/* Create a usage bar which keeps track of how much storage space is used
|
||||
by your CryptDrive. The getPinnedUsage RPC is one of the heavier calls,
|
||||
so we throttle its usage. Clients will not update more than once per
|
||||
LIMIT_REFRESH_RATE. It will be update at least once every three such intervals
|
||||
If changes are made to your drive in the interim, they will trigger an
|
||||
update.
|
||||
*/
|
||||
var LIMIT_REFRESH_RATE = 30000; // milliseconds
|
||||
UI.createUsageBar = function (common, cb) {
|
||||
if (!common.isLoggedIn()) { return cb("NOT_LOGGED_IN"); }
|
||||
// getPinnedUsage updates common.account.usage, and other values
|
||||
// so we can just use those and only check for errors
|
||||
var $container = $('<span>', {'class':'cp-limit-container'});
|
||||
var todo;
|
||||
var updateUsage = Cryptpad.notAgainForAnother(function () {
|
||||
common.getPinUsage(todo);
|
||||
}, LIMIT_REFRESH_RATE);
|
||||
|
||||
todo = function (err, data) {
|
||||
if (err) { return void console.error(err); }
|
||||
|
||||
var usage = data.usage;
|
||||
var limit = data.limit;
|
||||
var plan = data.plan;
|
||||
$container.html('');
|
||||
var unit = Util.magnitudeOfBytes(limit);
|
||||
|
||||
usage = unit === 'GB'? Util.bytesToGigabytes(usage):
|
||||
Util.bytesToMegabytes(usage);
|
||||
limit = unit === 'GB'? Util.bytesToGigabytes(limit):
|
||||
Util.bytesToMegabytes(limit);
|
||||
|
||||
var $limit = $('<span>', {'class': 'cp-limit-bar'}).appendTo($container);
|
||||
var quota = usage/limit;
|
||||
var $usage = $('<span>', {'class': 'cp-limit-usage'}).css('width', quota*100+'%');
|
||||
|
||||
var makeDonateButton = function () {
|
||||
$('<a>', {
|
||||
'class': 'cp-limit-upgrade btn btn-success',
|
||||
href: Cryptpad.donateURL,
|
||||
rel: "noreferrer noopener",
|
||||
target: "_blank",
|
||||
}).text(Messages.supportCryptpad).appendTo($container);
|
||||
};
|
||||
|
||||
var makeUpgradeButton = function () {
|
||||
$('<a>', {
|
||||
'class': 'cp-limit-upgrade btn btn-success',
|
||||
href: Cryptpad.upgradeURL,
|
||||
rel: "noreferrer noopener",
|
||||
target: "_blank",
|
||||
}).text(Messages.upgradeAccount).appendTo($container);
|
||||
};
|
||||
|
||||
if (!Config.removeDonateButton) {
|
||||
if (!common.isLoggedIn() || !Config.allowSubscriptions) {
|
||||
// user is not logged in, or subscriptions are disallowed
|
||||
makeDonateButton();
|
||||
} else if (!plan) {
|
||||
// user is logged in and subscriptions are allowed
|
||||
// and they don't have one. show upgrades
|
||||
makeUpgradeButton();
|
||||
} else {
|
||||
// they have a plan. show nothing
|
||||
}
|
||||
}
|
||||
|
||||
var prettyUsage;
|
||||
var prettyLimit;
|
||||
|
||||
if (unit === 'GB') {
|
||||
prettyUsage = Messages._getKey('formattedGB', [usage]);
|
||||
prettyLimit = Messages._getKey('formattedGB', [limit]);
|
||||
} else {
|
||||
prettyUsage = Messages._getKey('formattedMB', [usage]);
|
||||
prettyLimit = Messages._getKey('formattedMB', [limit]);
|
||||
}
|
||||
|
||||
if (quota < 0.8) { $usage.addClass('cp-limit-usage-normal'); }
|
||||
else if (quota < 1) { $usage.addClass('cp-limit-usage-warning'); }
|
||||
else { $usage.addClass('cp-limit-usage-above'); }
|
||||
var $text = $('<span>', {'class': 'cp-limit-usage-text'});
|
||||
$text.text(usage + ' / ' + prettyLimit);
|
||||
$limit.append($usage).append($text);
|
||||
};
|
||||
|
||||
setInterval(function () {
|
||||
updateUsage();
|
||||
}, LIMIT_REFRESH_RATE * 3);
|
||||
|
||||
updateUsage();
|
||||
/*getProxy().on('change', ['drive'], function () {
|
||||
updateUsage();
|
||||
}); TODO*/
|
||||
cb(null, $container);
|
||||
};
|
||||
|
||||
UI.createUserAdminMenu = function (Common, config) {
|
||||
var metadataMgr = Common.getMetadataMgr();
|
||||
|
||||
|
||||
@@ -44,14 +44,21 @@ define([
|
||||
localStorage.CRYPTPAD_URLARGS = ApiConfig.requireConf.urlArgs;
|
||||
}
|
||||
var cache = {};
|
||||
var localStore = {};
|
||||
Object.keys(localStorage).forEach(function (k) {
|
||||
if (k.indexOf('CRYPTPAD_CACHE|') !== 0) { return; }
|
||||
cache[k.slice(('CRYPTPAD_CACHE|').length)] = localStorage[k];
|
||||
if (k.indexOf('CRYPTPAD_CACHE|') === 0) {
|
||||
cache[k.slice(('CRYPTPAD_CACHE|').length)] = localStorage[k];
|
||||
return;
|
||||
}
|
||||
if (k.indexOf('CRYPTPAD_STORE|') === 0) {
|
||||
localStore[k.slice(('CRYPTPAD_STORE|').length)] = localStorage[k];
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
SFrameChannel.create($('#sbox-iframe')[0].contentWindow, waitFor(function (sfc) {
|
||||
sframeChan = sfc;
|
||||
}), false, { cache: cache, language: Cryptpad.getLanguage() });
|
||||
}), false, { cache: cache, localStore: localStore, language: Cryptpad.getLanguage() });
|
||||
Cryptpad.ready(waitFor());
|
||||
}));
|
||||
}).nThen(function (waitFor) {
|
||||
@@ -61,8 +68,17 @@ define([
|
||||
localStorage['CRYPTPAD_CACHE|' + k] = x[k];
|
||||
});
|
||||
});
|
||||
sframeChan.on('EV_LOCALSTORE_PUT', function (x) {
|
||||
Object.keys(x).forEach(function (k) {
|
||||
if (typeof(x[k]) === "undefined") {
|
||||
delete localStorage['CRYPTPAD_STORE|' + k];
|
||||
return;
|
||||
}
|
||||
localStorage['CRYPTPAD_STORE|' + k] = x[k];
|
||||
});
|
||||
});
|
||||
|
||||
secret = Cryptpad.getSecrets();
|
||||
secret = cfg.getSecrets ? cfg.getSecrets(Cryptpad) : Cryptpad.getSecrets();
|
||||
if (!secret.channel) {
|
||||
// New pad: create a new random channel id
|
||||
secret.channel = Cryptpad.createChannelId();
|
||||
@@ -278,6 +294,12 @@ define([
|
||||
});
|
||||
});
|
||||
|
||||
sframeChan.on('Q_SESSIONSTORAGE_PUT', function (data, cb) {
|
||||
sessionStorage[data.key] = data.value;
|
||||
cb();
|
||||
});
|
||||
|
||||
|
||||
// Present mode URL
|
||||
sframeChan.on('Q_PRESENT_URL_GET_VALUE', function (data, cb) {
|
||||
var parsed = Cryptpad.parsePadUrl(window.location.href);
|
||||
@@ -369,6 +391,12 @@ define([
|
||||
}
|
||||
});
|
||||
|
||||
sframeChan.on('EV_OPEN_URL', function (url) {
|
||||
if (url) {
|
||||
window.open(url);
|
||||
}
|
||||
});
|
||||
|
||||
sframeChan.on('Q_TAGS_GET', function (data, cb) {
|
||||
Cryptpad.getPadTags(null, function (err, data) {
|
||||
cb({
|
||||
@@ -383,6 +411,15 @@ define([
|
||||
Cryptpad.resetTags(null, data);
|
||||
});
|
||||
|
||||
sframeChan.on('Q_PIN_GET_USAGE', function (data, cb) {
|
||||
Cryptpad.isOverPinLimit(function (err, overLimit, data) {
|
||||
cb({
|
||||
error: err,
|
||||
data: data
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
if (cfg.addRpc) {
|
||||
cfg.addRpc(sframeChan, Cryptpad);
|
||||
}
|
||||
@@ -396,7 +433,7 @@ define([
|
||||
CpNfOuter.start({
|
||||
sframeChan: sframeChan,
|
||||
channel: secret.channel,
|
||||
network: Cryptpad.getNetwork(),
|
||||
network: cfg.newNetwork || Cryptpad.getNetwork(),
|
||||
validateKey: secret.keys.validateKey || undefined,
|
||||
readOnly: readOnly,
|
||||
crypto: Crypto.createEncryptor(secret.keys),
|
||||
@@ -408,7 +445,7 @@ define([
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (readOnly) { return; }
|
||||
if (readOnly || cfg.noHash) { return; }
|
||||
Cryptpad.replaceHash(Cryptpad.getEditHashFromKeys(wc.id, secret.keys));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -77,6 +77,7 @@ define([
|
||||
funcs.openTemplatePicker = callWithCommon(UI.openTemplatePicker);
|
||||
funcs.displayAvatar = callWithCommon(UI.displayAvatar);
|
||||
funcs.createButton = callWithCommon(UI.createButton);
|
||||
funcs.createUsageBar = callWithCommon(UI.createUsageBar);
|
||||
|
||||
// History
|
||||
funcs.getHistory = callWithCommon(History.create);
|
||||
@@ -156,6 +157,12 @@ define([
|
||||
if (cb) { cb(data); }
|
||||
});
|
||||
};
|
||||
funcs.getPinUsage = function (cb) {
|
||||
cb = cb || $.noop;
|
||||
ctx.sframeChan.query('Q_PIN_GET_USAGE', null, function (err, data) {
|
||||
cb(err || data.error, data.data);
|
||||
});
|
||||
};
|
||||
|
||||
funcs.isOverPinLimit = function (cb) {
|
||||
ctx.sframeChan.query('Q_GET_PIN_LIMIT_STATUS', null, function (err, data) {
|
||||
@@ -203,6 +210,15 @@ define([
|
||||
}, cb);
|
||||
};
|
||||
|
||||
funcs.sessionStorage = {
|
||||
put: function (key, value, cb) {
|
||||
ctx.sframeChan.query('Q_SESSIONSTORAGE_PUT', {
|
||||
key: key,
|
||||
value: value
|
||||
}, cb);
|
||||
}
|
||||
};
|
||||
|
||||
funcs.isStrongestStored = function () {
|
||||
var data = ctx.metadataMgr.getPrivateData();
|
||||
if (data.availableHashes.fileHash) { return true; }
|
||||
@@ -214,6 +230,9 @@ define([
|
||||
ctx.sframeChan.query('Q_SETTINGS_SET_DISPLAY_NAME', name, cb);
|
||||
};
|
||||
|
||||
funcs.mergeAnonDrive = function (cb) {
|
||||
ctx.sframeChan.query('Q_MERGE_ANON_DRIVE', null, cb);
|
||||
};
|
||||
// Friends
|
||||
var pendingFriends = [];
|
||||
funcs.getPendingFriends = function () {
|
||||
@@ -264,6 +283,7 @@ define([
|
||||
}; */
|
||||
|
||||
funcs.gotoURL = function (url) { ctx.sframeChan.event('EV_GOTO_URL', url); };
|
||||
funcs.openURL = function (url) { ctx.sframeChan.event('EV_OPEN_URL', url); };
|
||||
|
||||
funcs.whenRealtimeSyncs = evRealtimeSynced.reg;
|
||||
|
||||
@@ -287,6 +307,18 @@ define([
|
||||
ctx.sframeChan.event('EV_CACHE_PUT', x);
|
||||
};
|
||||
});
|
||||
ctx.sframeChan.whenReg('EV_LOCALSTORE_PUT', function () {
|
||||
if (Object.keys(window.cryptpadStore.updated).length) {
|
||||
ctx.sframeChan.event('EV_LOCALSTORE_PUT', window.cryptpadStore.updated);
|
||||
}
|
||||
window.cryptpadStore._put = window.cryptpadStore.put;
|
||||
window.cryptpadStore.put = function (k, v, cb) {
|
||||
window.cryptpadStore._put(k, v, cb);
|
||||
var x = {};
|
||||
x[k] = v;
|
||||
ctx.sframeChan.event('EV_LOCALSTORE_PUT', x);
|
||||
};
|
||||
});
|
||||
|
||||
UI.addTooltips();
|
||||
|
||||
|
||||
@@ -67,6 +67,9 @@ define({
|
||||
// Use anonymous rpc from inside the iframe (for avatars & pin usage).
|
||||
'Q_ANON_RPC_MESSAGE': true,
|
||||
|
||||
// Get the user's pin limit, usage and plan
|
||||
'Q_PIN_GET_USAGE': true,
|
||||
|
||||
// Check the pin limit to determine if we can store the pad in the drive or if we should.
|
||||
// display a warning
|
||||
'Q_GET_PIN_LIMIT_STATUS': true,
|
||||
@@ -123,16 +126,28 @@ define({
|
||||
|
||||
// Make the browser window navigate to a given URL, if no URL is passed then it will reload.
|
||||
'EV_GOTO_URL': true,
|
||||
// Make the parent window open a given URL in a new tab. It allows us to keep sessionStorage
|
||||
// form the parent window.
|
||||
'EV_OPEN_URL': true,
|
||||
|
||||
// Present mode URL
|
||||
'Q_PRESENT_URL_GET_VALUE': true,
|
||||
'EV_PRESENT_URL_SET_VALUE': true,
|
||||
|
||||
// Put one or more entries to the cache which will go in localStorage.
|
||||
// Cache is wiped after each new release
|
||||
'EV_CACHE_PUT': true,
|
||||
// Put one or more entries to the localStore which will go in localStorage.
|
||||
'EV_LOCALSTORE_PUT': true,
|
||||
// Put one entry in the parent sessionStorage
|
||||
'Q_SESSIONSTORAGE_PUT': true,
|
||||
|
||||
// Set and get the tags using the tag prompt button
|
||||
'Q_TAGS_GET': true,
|
||||
'EV_TAGS_SET': true,
|
||||
|
||||
// Merge the anonymous drive (FS_hash) into the current logged in user's drive, to keep the pads
|
||||
// in the drive at registration.
|
||||
'Q_MERGE_ANON_DRIVE': true,
|
||||
|
||||
});
|
||||
|
||||
@@ -18,6 +18,7 @@ define([
|
||||
var exp = {};
|
||||
var Cryptpad = config.Cryptpad;
|
||||
var Messages = Cryptpad.Messages;
|
||||
var loggedIn = config.loggedIn || Cryptpad.isLoggedIn();
|
||||
|
||||
var FILES_DATA = module.FILES_DATA = exp.FILES_DATA = Cryptpad.storageKey;
|
||||
var OLD_FILES_DATA = module.OLD_FILES_DATA = exp.OLD_FILES_DATA = Cryptpad.oldStorageKey;
|
||||
@@ -481,13 +482,14 @@ define([
|
||||
|
||||
// FILES DATA
|
||||
exp.pushData = function (data, cb) {
|
||||
// TODO: can only be called from outside atm
|
||||
if (typeof cb !== "function") { cb = function () {}; }
|
||||
var todo = function () {
|
||||
var id = Cryptpad.createRandomInteger();
|
||||
files[FILES_DATA][id] = data;
|
||||
cb(null, id);
|
||||
};
|
||||
if (!Cryptpad.isLoggedIn() || !AppConfig.enablePinning || config.testMode) {
|
||||
if (!loggedIn || !AppConfig.enablePinning || config.testMode) {
|
||||
return void todo();
|
||||
}
|
||||
Cryptpad.pinPads([Cryptpad.hrefToHexChannelId(data.href)], function (e) {
|
||||
@@ -585,7 +587,7 @@ define([
|
||||
|
||||
// ADD
|
||||
var add = exp.add = function (id, path) {
|
||||
if (!Cryptpad.isLoggedIn() && !config.testMode) { return; }
|
||||
if (!loggedIn && !config.testMode) { return; }
|
||||
var data = files[FILES_DATA][id];
|
||||
if (!data || typeof(data) !== "object") { return; }
|
||||
var newPath = path, parentEl;
|
||||
@@ -624,7 +626,7 @@ define([
|
||||
exp.forget = function (href) {
|
||||
var id = getIdFromHref(href);
|
||||
if (!id) { return; }
|
||||
if (!Cryptpad.isLoggedIn() && !config.testMode) {
|
||||
if (!loggedIn && !config.testMode) {
|
||||
// delete permanently
|
||||
exp.removePadAttribute(href);
|
||||
spliceFileData(id);
|
||||
@@ -653,7 +655,7 @@ define([
|
||||
};
|
||||
var checkDeletedFiles = function () {
|
||||
// Nothing in OLD_FILES_DATA for workgroups
|
||||
if (workgroup || (!Cryptpad.isLoggedIn() && !config.testMode)) { return; }
|
||||
if (workgroup || (!loggedIn && !config.testMode)) { return; }
|
||||
|
||||
var filesList = getFiles([ROOT, 'hrefArray', TRASH]);
|
||||
getFiles([FILES_DATA]).forEach(function (id) {
|
||||
@@ -680,7 +682,7 @@ define([
|
||||
var trashPaths = paths.filter(function(x) { return isPathIn(x, [TRASH]); });
|
||||
var allFilesPaths = paths.filter(function(x) { return isPathIn(x, [FILES_DATA]); });
|
||||
|
||||
if (!Cryptpad.isLoggedIn() && !config.testMode) {
|
||||
if (!loggedIn && !config.testMode) {
|
||||
allFilesPaths.forEach(function (path) {
|
||||
var el = find(path);
|
||||
if (!el) { return; }
|
||||
@@ -855,6 +857,7 @@ define([
|
||||
}
|
||||
try {
|
||||
debug("Migrating file system...");
|
||||
// TODO
|
||||
Cryptpad.feedback('Migrate-oldFilesData', true);
|
||||
files.migrate = 1;
|
||||
var next = function () {
|
||||
@@ -904,6 +907,7 @@ define([
|
||||
};
|
||||
if (exp.rt) {
|
||||
exp.rt.sync();
|
||||
// TODO
|
||||
Cryptpad.whenRealtimeSyncs(exp.rt, next);
|
||||
} else {
|
||||
window.setTimeout(next, 1000);
|
||||
@@ -1063,7 +1067,7 @@ define([
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((Cryptpad.isLoggedIn() || config.testMode) && rootFiles.indexOf(id) === -1) {
|
||||
if ((loggedIn || config.testMode) && rootFiles.indexOf(id) === -1) {
|
||||
debug("An element in filesData was not in ROOT, TEMPLATE or TRASH.", id, el);
|
||||
var newName = Cryptpad.createChannelId();
|
||||
root[newName] = id;
|
||||
|
||||
Reference in New Issue
Block a user