Put constants in a separate file

pull/1/head
yflory 7 years ago
parent 7f88d1d43a
commit 477f14bb8b

@ -4,8 +4,9 @@ define([
'/common/cryptpad-common.js', '/common/cryptpad-common.js',
'/common/common-interface.js', '/common/common-interface.js',
'/common/common-realtime.js', '/common/common-realtime.js',
'/common/common-constants.js',
'/customize/messages.js', '/customize/messages.js',
], function ($, Config, Cryptpad, UI, Realtime, Messages) { ], function ($, Config, Cryptpad, UI, Realtime, Constants, Messages) {
window.APP = { window.APP = {
Cryptpad: Cryptpad, Cryptpad: Cryptpad,
@ -33,7 +34,7 @@ define([
$main.find('a[href="/drive/"] div.pad-button-text h4') $main.find('a[href="/drive/"] div.pad-button-text h4')
.text(Messages.main_yourCryptDrive); .text(Messages.main_yourCryptDrive);
var name = localStorage[Cryptpad.userNameKey] || sessionStorage[Cryptpad.userNameKey]; var name = localStorage[Constants.userNameKey] || sessionStorage[Constants.userNameKey];
var $loggedInBlock = $main.find('#loggedIn'); var $loggedInBlock = $main.find('#loggedIn');
var $hello = $loggedInBlock.find('#loggedInHello'); var $hello = $loggedInBlock.find('#loggedInHello');
var $logout = $loggedInBlock.find('#loggedInLogOut'); var $logout = $loggedInBlock.find('#loggedInLogOut');

@ -4,11 +4,12 @@ define([
'/common/curve.js', '/common/curve.js',
'/common/common-hash.js', '/common/common-hash.js',
'/common/common-util.js', '/common/common-util.js',
'/common/common-constants.js',
'/customize/messages.js', '/customize/messages.js',
'/bower_components/marked/marked.min.js', '/bower_components/marked/marked.min.js',
'/common/common-realtime.js', '/common/common-realtime.js',
], function ($, Crypto, Curve, Hash, Util, Messages, Marked, Realtime) { ], function ($, Crypto, Curve, Hash, Util, Constants, Messages, Marked, Realtime) {
var Msg = { var Msg = {
inputs: [], inputs: [],
}; };
@ -88,7 +89,7 @@ define([
if (e) { console.error(e); } if (e) { console.error(e); }
}); });
}); });
common.changeDisplayName(proxy[common.displayNameKey]); common.changeDisplayName(proxy[Constants.displayNameKey]);
}; };
/* Used to accept friend requests within apps other than /contacts/ */ /* Used to accept friend requests within apps other than /contacts/ */
@ -170,7 +171,7 @@ define([
logText: Messages.contacts_rejected, logText: Messages.contacts_rejected,
netfluxId: sender netfluxId: sender
}); });
common.changeDisplayName(proxy[common.displayNameKey]); common.changeDisplayName(proxy[Constants.displayNameKey]);
return; return;
} }
if (msg[0] === "FRIEND_REQ_ACK") { if (msg[0] === "FRIEND_REQ_ACK") {
@ -220,7 +221,7 @@ define([
var proxy = common.getProxy(); var proxy = common.getProxy();
// this redraws the userlist after a change has occurred // this redraws the userlist after a change has occurred
// TODO rename this function to reflect its purpose // TODO rename this function to reflect its purpose
common.changeDisplayName(proxy[common.displayNameKey]); common.changeDisplayName(proxy[Constants.displayNameKey]);
} }
network.sendto(netfluxId, msgStr); network.sendto(netfluxId, msgStr);
}; };

@ -9,6 +9,7 @@ define([
'/file/file-crypto.js', '/file/file-crypto.js',
'/common/common-realtime.js', '/common/common-realtime.js',
'/common/common-language.js', '/common/common-language.js',
'/common/common-constants.js',
'/common/clipboard.js', '/common/clipboard.js',
'/common/pinpad.js', '/common/pinpad.js',
@ -17,7 +18,7 @@ define([
'/bower_components/nthen/index.js', '/bower_components/nthen/index.js',
'/bower_components/localforage/dist/localforage.min.js', '/bower_components/localforage/dist/localforage.min.js',
], function ($, Config, Messages, Store, Util, Hash, ], function ($, Config, Messages, Store, Util, Hash,
Messaging, FileCrypto, Realtime, Language, Clipboard, Messaging, FileCrypto, Realtime, Language, Constants, Clipboard,
Pinpad, AppConfig, MediaTag, Nthen, localForage) { Pinpad, AppConfig, MediaTag, Nthen, localForage) {
// Configure MediaTags to use our local viewer // Configure MediaTags to use our local viewer
@ -42,14 +43,6 @@ define([
MediaTag: MediaTag, MediaTag: MediaTag,
}; };
// constants
var userHashKey = common.userHashKey = 'User_hash';
var userNameKey = common.userNameKey = 'User_name';
var fileHashKey = common.fileHashKey = 'FS_hash';
common.displayNameKey = 'cryptpad.username';
var newPadPathKey = common.newPadPathKey = "newPadPath";
common.oldStorageKey = 'CryptPad_RECENTPADS';
common.storageKey = 'filesData';
var PINNING_ENABLED = AppConfig.enablePinning; var PINNING_ENABLED = AppConfig.enablePinning;
var store; var store;
@ -158,14 +151,14 @@ define([
common.getDisplayName = function (cb) { common.getDisplayName = function (cb) {
var name; var name;
if (getProxy()) { if (getProxy()) {
name = getProxy()[common.displayNameKey]; name = getProxy()[Constants.displayNameKey];
} }
name = name || ''; name = name || '';
if (typeof cb === "function") { cb(null, name); } if (typeof cb === "function") { cb(null, name); }
return name; return name;
}; };
common.getAccountName = function () { common.getAccountName = function () {
return localStorage[common.userNameKey]; return localStorage[Constants.userNameKey];
}; };
// REFACTOR: move to util? // REFACTOR: move to util?
@ -250,8 +243,8 @@ define([
if (!hash) { throw new Error('expected a user hash'); } if (!hash) { throw new Error('expected a user hash'); }
if (!name) { throw new Error('expected a user name'); } if (!name) { throw new Error('expected a user name'); }
hash = Hash.serializeHash(hash); hash = Hash.serializeHash(hash);
localStorage.setItem(userHashKey, hash); localStorage.setItem(Constants.userHashKey, hash);
localStorage.setItem(userNameKey, name); localStorage.setItem(Constants.userNameKey, name);
if (cb) { cb(); } if (cb) { cb(); }
}; };
@ -272,8 +265,8 @@ define([
var logoutHandlers = []; var logoutHandlers = [];
common.logout = function (cb) { common.logout = function (cb) {
[ [
userNameKey, Constants.userNameKey,
userHashKey, Constants.userHashKey,
'loginToken', 'loginToken',
'plan', 'plan',
].forEach(function (k) { ].forEach(function (k) {
@ -285,8 +278,8 @@ define([
localForage.clear(); localForage.clear();
// Make sure we have an FS_hash in localStorage before reloading all the tabs // Make sure we have an FS_hash in localStorage before reloading all the tabs
// so that we don't end up with tabs using different anon hashes // so that we don't end up with tabs using different anon hashes
if (!localStorage[fileHashKey]) { if (!localStorage[Constants.fileHashKey]) {
localStorage[fileHashKey] = Hash.createRandomHash(); localStorage[Constants.fileHashKey] = Hash.createRandomHash();
} }
eraseTempSessionValues(); eraseTempSessionValues();
@ -303,16 +296,16 @@ define([
}; };
var getUserHash = common.getUserHash = function () { var getUserHash = common.getUserHash = function () {
var hash = localStorage[userHashKey]; var hash = localStorage[Constants.userHashKey];
if (['undefined', 'undefined/'].indexOf(hash) !== -1) { if (['undefined', 'undefined/'].indexOf(hash) !== -1) {
localStorage.removeItem(userHashKey); localStorage.removeItem(Constants.userHashKey);
return; return;
} }
if (hash) { if (hash) {
var sHash = Hash.serializeHash(hash); var sHash = Hash.serializeHash(hash);
if (sHash !== hash) { localStorage[userHashKey] = sHash; } if (sHash !== hash) { localStorage[Constants.userHashKey] = sHash; }
} }
return hash; return hash;
@ -365,7 +358,7 @@ define([
}; };
common.setDisplayName = function (value, cb) { common.setDisplayName = function (value, cb) {
if (getProxy()) { if (getProxy()) {
getProxy()[common.displayNameKey] = value; getProxy()[Constants.displayNameKey] = value;
} }
if (typeof cb === "function") { Realtime.whenRealtimeSyncs(getRealtime(), cb); } if (typeof cb === "function") { Realtime.whenRealtimeSyncs(getRealtime(), cb); }
}; };
@ -716,7 +709,7 @@ define([
var fo = proxy.fo; var fo = proxy.fo;
// start with your userHash... // start with your userHash...
var userHash = localStorage && localStorage.User_hash; var userHash = localStorage && localStorage[Constants.userHashKey];
if (!userHash) { return null; } if (!userHash) { return null; }
var userParsedHash = Hash.parseTypeHash('drive', userHash); var userParsedHash = Hash.parseTypeHash('drive', userHash);
@ -1070,9 +1063,9 @@ define([
return void setTimeout(function () { f(void 0, env); }); return void setTimeout(function () { f(void 0, env); });
} }
if (sessionStorage[newPadPathKey]) { if (sessionStorage[Constants.newPadPathKey]) {
common.initialPath = sessionStorage[newPadPathKey]; common.initialPath = sessionStorage[Constants.newPadPathKey];
delete sessionStorage[newPadPathKey]; delete sessionStorage[Constants.newPadPathKey];
} }
var proxy; var proxy;
@ -1138,7 +1131,7 @@ define([
}; };
// Listen for login/logout in other tabs // Listen for login/logout in other tabs
window.addEventListener('storage', function (e) { window.addEventListener('storage', function (e) {
if (e.key !== common.userHashKey) { return; } if (e.key !== Constants.userHashKey) { return; }
var o = e.oldValue; var o = e.oldValue;
var n = e.newValue; var n = e.newValue;
if (!o && n) { if (!o && n) {

@ -6,8 +6,9 @@ define([
'/common/userObject.js', '/common/userObject.js',
'/common/common-interface.js', '/common/common-interface.js',
'/common/common-hash.js', '/common/common-hash.js',
'/common/common-constants.js',
'/common/migrate-user-object.js', '/common/migrate-user-object.js',
], function ($, Listmap, Crypto, TextPatcher, FO, UI, Hash, Migrate) { ], function ($, Listmap, Crypto, TextPatcher, FO, UI, Hash, Constants, Migrate) {
/* /*
This module uses localStorage, which is synchronous, but exposes an This module uses localStorage, which is synchronous, but exposes an
asyncronous API. This is so that we can substitute other storage asyncronous API. This is so that we can substitute other storage
@ -191,7 +192,7 @@ define([
var onReady = function (f, proxy, Cryptpad, exp) { var onReady = function (f, proxy, Cryptpad, exp) {
var fo = exp.fo = FO.init(proxy.drive, { var fo = exp.fo = FO.init(proxy.drive, {
Cryptpad: Cryptpad, Cryptpad: Cryptpad,
rt: exp.realtime loggedIn: Cryptpad.isLoggedIn()
}); });
var todo = function () { var todo = function () {
fo.fixFiles(); fo.fixFiles();
@ -258,17 +259,17 @@ define([
return void requestLogin(); return void requestLogin();
} }
proxy.on('change', [Cryptpad.displayNameKey], function (o, n) { proxy.on('change', [Constants.displayNameKey], function (o, n) {
if (typeof(n) !== "string") { return; } if (typeof(n) !== "string") { return; }
Cryptpad.changeDisplayName(n); Cryptpad.changeDisplayName(n);
}); });
proxy.on('change', ['profile'], function () { proxy.on('change', ['profile'], function () {
// Trigger userlist update when the avatar has changed // Trigger userlist update when the avatar has changed
Cryptpad.changeDisplayName(proxy[Cryptpad.displayNameKey]); Cryptpad.changeDisplayName(proxy[Constants.displayNameKey]);
}); });
proxy.on('change', ['friends'], function () { proxy.on('change', ['friends'], function () {
// Trigger userlist update when the avatar has changed // Trigger userlist update when the avatar has changed
Cryptpad.changeDisplayName(proxy[Cryptpad.displayNameKey]); Cryptpad.changeDisplayName(proxy[Constants.displayNameKey]);
}); });
proxy.on('change', [tokenKey], function () { proxy.on('change', [tokenKey], function () {
var localToken = tryParsing(localStorage.getItem(tokenKey)); var localToken = tryParsing(localStorage.getItem(tokenKey));
@ -318,9 +319,9 @@ define([
if (!rt.proxy.drive || typeof(rt.proxy.drive) !== 'object') { rt.proxy.drive = {}; } if (!rt.proxy.drive || typeof(rt.proxy.drive) !== 'object') { rt.proxy.drive = {}; }
var drive = rt.proxy.drive; var drive = rt.proxy.drive;
// Creating a new anon drive: import anon pads from localStorage // Creating a new anon drive: import anon pads from localStorage
if ((!drive[Cryptpad.oldStorageKey] || !Cryptpad.isArray(drive[Cryptpad.oldStorageKey])) if ((!drive[Constants.oldStorageKey] || !Array.isArray(drive[Constants.oldStorageKey]))
&& !drive['filesData']) { && !drive['filesData']) {
drive[Cryptpad.oldStorageKey] = []; drive[Constants.oldStorageKey] = [];
onReady(f, rt.proxy, Cryptpad, exp); onReady(f, rt.proxy, Cryptpad, exp);
return; return;
} }

@ -105,7 +105,7 @@ define([
if (parsed) { if (parsed) {
var proxy = proxyData.proxy; var proxy = proxyData.proxy;
var oldFo = FO.init(parsed.drive, { var oldFo = FO.init(parsed.drive, {
Cryptpad: Cryptpad loggedIn: Cryptpad.isLoggedIn()
}); });
var onMigrated = function () { var onMigrated = function () {
oldFo.fixFiles(); oldFo.fixFiles();

@ -3,8 +3,10 @@ define([
'/customize/application_config.js', '/customize/application_config.js',
'/common/common-util.js', '/common/common-util.js',
'/common/common-hash.js', '/common/common-hash.js',
'/common/common-realtime.js' '/common/common-realtime.js',
], function ($, AppConfig, Util, Hash, Realtime) { '/common/common-constants.js',
'/customize/messages.js'
], function ($, AppConfig, Util, Hash, Realtime, Constants, Messages) {
var module = {}; var module = {};
var ROOT = module.ROOT = "root"; var ROOT = module.ROOT = "root";
@ -20,11 +22,10 @@ define([
module.init = function (files, config) { module.init = function (files, config) {
var exp = {}; var exp = {};
var Cryptpad = config.Cryptpad; var Cryptpad = config.Cryptpad;
var Messages = Cryptpad.Messages; var loggedIn = config.loggedIn;
var loggedIn = config.loggedIn || Cryptpad.isLoggedIn();
var FILES_DATA = module.FILES_DATA = exp.FILES_DATA = Cryptpad.storageKey; var FILES_DATA = module.FILES_DATA = exp.FILES_DATA = Constants.storageKey;
var OLD_FILES_DATA = module.OLD_FILES_DATA = exp.OLD_FILES_DATA = Cryptpad.oldStorageKey; var OLD_FILES_DATA = module.OLD_FILES_DATA = exp.OLD_FILES_DATA = Constants.oldStorageKey;
var NEW_FOLDER_NAME = Messages.fm_newFolder; var NEW_FOLDER_NAME = Messages.fm_newFolder;
var NEW_FILE_NAME = Messages.fm_newFile; var NEW_FILE_NAME = Messages.fm_newFile;
@ -487,6 +488,7 @@ define([
// FILES DATA // FILES DATA
exp.pushData = function (data, cb) { exp.pushData = function (data, cb) {
// TODO: can only be called from outside atm // TODO: can only be called from outside atm
if (!Cryptpad) { return; }
if (typeof cb !== "function") { cb = function () {}; } if (typeof cb !== "function") { cb = function () {}; }
var todo = function () { var todo = function () {
var id = Util.createRandomInteger(); var id = Util.createRandomInteger();
@ -855,8 +857,6 @@ define([
} }
try { try {
debug("Migrating file system..."); debug("Migrating file system...");
// TODO
Cryptpad.feedback('Migrate-oldFilesData', true);
files.migrate = 1; files.migrate = 1;
var next = function () { var next = function () {
var oldData = files[OLD_FILES_DATA].slice(); var oldData = files[OLD_FILES_DATA].slice();

@ -3,11 +3,11 @@ define([
'/bower_components/textpatcher/TextPatcher.js', '/bower_components/textpatcher/TextPatcher.js',
'/common/toolbar3.js', '/common/toolbar3.js',
'json.sortify', 'json.sortify',
'/common/cryptpad-common.js',
'/common/common-util.js', '/common/common-util.js',
'/common/common-hash.js', '/common/common-hash.js',
'/common/common-ui-elements.js', '/common/common-ui-elements.js',
'/common/common-interface.js', '/common/common-interface.js',
'/common/common-constants.js',
'/common/cryptget.js', '/common/cryptget.js',
'/bower_components/nthen/index.js', '/bower_components/nthen/index.js',
'/common/sframe-common.js', '/common/sframe-common.js',
@ -25,11 +25,11 @@ define([
TextPatcher, TextPatcher,
Toolbar, Toolbar,
JSONSortify, JSONSortify,
Cryptpad,
Util, Util,
Hash, Hash,
UIElements, UIElements,
UI, UI,
Constants,
Cryptget, Cryptget,
nThen, nThen,
SFCommon, SFCommon,
@ -41,7 +41,6 @@ define([
{ {
var APP = window.APP = { var APP = window.APP = {
editable: false, editable: false,
Cryptpad: Cryptpad,
mobile: function () { return $('body').width() <= 600; } // Menu and content area are not inline-block anymore for mobiles mobile: function () { return $('body').width() <= 600; } // Menu and content area are not inline-block anymore for mobiles
}; };
@ -55,7 +54,7 @@ define([
var SEARCH_NAME = Messages.fm_searchName; var SEARCH_NAME = Messages.fm_searchName;
var ROOT = "root"; var ROOT = "root";
var ROOT_NAME = Messages.fm_rootName; var ROOT_NAME = Messages.fm_rootName;
var FILES_DATA = Cryptpad.storageKey; var FILES_DATA = Constants.storageKey;
var FILES_DATA_NAME = Messages.fm_filesDataName; var FILES_DATA_NAME = Messages.fm_filesDataName;
var TEMPLATE = "template"; var TEMPLATE = "template";
var TEMPLATE_NAME = Messages.fm_templateName; var TEMPLATE_NAME = Messages.fm_templateName;
@ -195,13 +194,11 @@ define([
var user = metadataMgr.getUserData(); var user = metadataMgr.getUserData();
var isOwnDrive = function () { var isOwnDrive = function () {
return true; // TODO return true; // TODO
//return Cryptpad.getUserHash() === APP.hash || localStorage.FS_hash === APP.hash;
}; };
var isWorkgroup = function () { var isWorkgroup = function () {
return files.workgroup === 1; return files.workgroup === 1;
}; };
config.workgroup = isWorkgroup(); config.workgroup = isWorkgroup();
config.Cryptpad = Cryptpad;
config.loggedIn = APP.loggedIn; config.loggedIn = APP.loggedIn;
APP.origin = priv.origin; APP.origin = priv.origin;
@ -1505,7 +1502,7 @@ define([
.click(function () { .click(function () {
var type = $(this).attr('data-type') || 'pad'; var type = $(this).attr('data-type') || 'pad';
var path = filesOp.isPathIn(currentPath, [TRASH]) ? '' : currentPath; var path = filesOp.isPathIn(currentPath, [TRASH]) ? '' : currentPath;
common.sessionStorage.put(Cryptpad.newPadPathKey, path, function () { common.sessionStorage.put(Constants.newPadPathKey, path, function () {
common.openURL('/' + type + '/'); common.openURL('/' + type + '/');
}); });
}); });
@ -2695,8 +2692,10 @@ define([
} }
else if ($(this).hasClass("cp-app-drive-context-newdoc")) { else if ($(this).hasClass("cp-app-drive-context-newdoc")) {
var type = $(this).data('type') || 'pad'; var type = $(this).data('type') || 'pad';
sessionStorage[Cryptpad.newPadPathKey] = filesOp.isPathIn(currentPath, [TRASH]) ? '' : currentPath; var path2 = filesOp.isPathIn(currentPath, [TRASH]) ? '' : currentPath;
window.open(APP.origin + '/' + type + '/'); common.sessionStorage.put(Constants.newPadPathKey, path2, function () {
common.openURL('/' + type + '/');
});
} }
APP.hideMenu(); APP.hideMenu();
}); });
@ -3008,26 +3007,6 @@ define([
$toolbar: APP.$bar, $toolbar: APP.$bar,
}; };
/* TODO iframe: backup button here?
if (!readOnly && !APP.loggedIn) {
// TODO secure drive
// cryptpad-backup --> cp-toolbar-backup
var $backupButton = Cryptpad.createButton('', true).removeClass('fa').removeClass('fa-question').addClass('cryptpad-backup');
$backupButton.append($backupIcon.clone().css('marginRight', '0px'));
$backupButton.attr('title', Messages.fm_backup_title);
$backupButton.on('click', function() {
var url = window.location.origin + window.location.pathname + '#' + editHash;
var msg = Messages.fm_alert_backupUrl + '<input type="text" readonly="readonly" id="fm_backupUrl" value="'+url+'">';
UI.alert(msg, undefined, true);
$('#fm_backupUrl').val(url);
$('#fm_backupUrl').click(function () {
$(this).select();
});
});
$userBlock.append($backupButton);
}
*/
metadataMgr.onChange(function () { metadataMgr.onChange(function () {
var name = metadataMgr.getUserData().name || Messages.anonymous; var name = metadataMgr.getUserData().name || Messages.anonymous;
APP.$displayName.text(name); APP.$displayName.text(name);

@ -69,7 +69,12 @@ define([
}; };
module.test = function (assert) { module.test = function (assert) {
var config = {Cryptpad: Cryptpad, workgroup: false, testMode: true}; var config = {
Cryptpad: Cryptpad,
workgroup: false,
testMode: true,
loggedIn: false
};
// MIGRATION FROM HREF TO ID // MIGRATION FROM HREF TO ID
assert(function (cb) { assert(function (cb) {

@ -7,9 +7,10 @@ define([
'/common/common-interface.js', '/common/common-interface.js',
'/common/common-util.js', '/common/common-util.js',
'/common/common-realtime.js', '/common/common-realtime.js',
'/common/common-constants.js',
'less!/bower_components/components-font-awesome/css/font-awesome.min.css', 'less!/bower_components/components-font-awesome/css/font-awesome.min.css',
], function ($, Login, Cryptpad, Test, Cred, UI, Util, Realtime) { ], function ($, Login, Cryptpad, Test, Cred, UI, Util, Realtime, Constants) {
var Messages = Cryptpad.Messages; var Messages = Cryptpad.Messages;
$(function () { $(function () {
@ -174,8 +175,8 @@ define([
if (!yes) { return; } if (!yes) { return; }
proxy.login_name = uname; proxy.login_name = uname;
if (!proxy[Cryptpad.displayNameKey]) { if (!proxy[Constants.displayNameKey]) {
proxy[Cryptpad.displayNameKey] = uname; proxy[Constants.displayNameKey] = uname;
} }
Cryptpad.eraseTempSessionValues(); Cryptpad.eraseTempSessionValues();
logMeIn(result); logMeIn(result);
@ -197,7 +198,7 @@ define([
} }
proxy.login_name = uname; proxy.login_name = uname;
proxy[Cryptpad.displayNameKey] = uname; proxy[Constants.displayNameKey] = uname;
sessionStorage.createReadme = 1; sessionStorage.createReadme = 1;
logMeIn(result); logMeIn(result);

@ -36,17 +36,6 @@ define([
}; };
window.addEventListener('message', onMsg); window.addEventListener('message', onMsg);
}).nThen(function (/*waitFor*/) { }).nThen(function (/*waitFor*/) {
/* TODO
window.addEventListener('storage', function (e) {
if (e.key !== Cryptpad.userHashKey) { return; }
var o = e.oldValue;
var n = e.newValue;
window.location.reload();
if (o && !n) { // disconnect
//redirectToMain();
}
});
*/
var addRpc = function (sframeChan, Cryptpad, Utils) { var addRpc = function (sframeChan, Cryptpad, Utils) {
sframeChan.on('Q_THUMBNAIL_CLEAR', function (d, cb) { sframeChan.on('Q_THUMBNAIL_CLEAR', function (d, cb) {
Cryptpad.clearThumbnail(function (err, data) { Cryptpad.clearThumbnail(function (err, data) {
@ -58,8 +47,11 @@ define([
}); });
sframeChan.on('Q_SETTINGS_DRIVE_SET', function (data, cb) { sframeChan.on('Q_SETTINGS_DRIVE_SET', function (data, cb) {
var sjson = JSON.stringify(data); var sjson = JSON.stringify(data);
var k = Cryptpad.getUserHash() || localStorage[Cryptpad.fileHashKey]; require([
require(['/common/cryptget.js'], function (Crypt) { '/common/cryptget.js',
'/common/common-constants.js'
], function (Crypt, Constants) {
var k = Cryptpad.getUserHash() || localStorage[Constants.fileHashKey];
Crypt.put(k, sjson, function (err) { Crypt.put(k, sjson, function (err) {
cb(err); cb(err);
}); });
@ -81,8 +73,11 @@ define([
}); });
sframeChan.on('Q_SETTINGS_IMPORT_LOCAL', function (data, cb) { sframeChan.on('Q_SETTINGS_IMPORT_LOCAL', function (data, cb) {
var proxyData = Cryptpad.getStore().getProxy(); var proxyData = Cryptpad.getStore().getProxy();
require(['/common/mergeDrive.js'], function (Merge) { require([
Merge.anonDriveIntoUser(proxyData, localStorage.FS_hash, cb); '/common/mergeDrive.js',
'/common/common-constants.js'
], function (Merge, Constants) {
Merge.anonDriveIntoUser(proxyData, localStorage[Constants.fileHashKey], cb);
}); });
}); });
}; };

Loading…
Cancel
Save