From f2faeaad07e8edccbe3ac412f90f0ef571c5c7c9 Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 2 Nov 2020 12:55:40 +0100 Subject: [PATCH] Backward compatiility with sessionStorage --- www/common/cryptpad-common.js | 26 ++++++++++++++++++++++++-- www/common/sframe-common-outer.js | 7 ++++++- www/register/main.js | 2 +- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index 36413d89d..8874871d8 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -2107,6 +2107,28 @@ define([ driveEvents: true //rdyCfg.driveEvents // Boolean }; + // FIXME Backward compatibility + if (sessionStorage.newPadFileData) { + common.fromFileData = JSON.parse(sessionStorage.newPadFileData); + var _parsed1 = Hash.parsePadUrl(common.fromFileData.href); + var _parsed2 = Hash.parsePadUrl(window.location.href); + if (_parsed1.hashData.type === 'pad') { + if (_parsed1.type !== _parsed2.type) { delete common.fromFileData; } + } + delete sessionStorage.newPadFileData; + } + + if (sessionStorage.newPadPath) { + common.initialPath = sessionStorage.newPadPath; + delete sessionStorage.newPadPath; + } + + if (sessionStorage.newPadTeam) { + common.initialTeam = sessionStorage.newPadTeam; + delete sessionStorage.newPadTeam; + } + + var channelIsReady = waitFor(); var msgEv = Util.mkEvent(); @@ -2332,7 +2354,7 @@ define([ postMessage("DISCONNECT"); }); }).nThen(function (waitFor) { - if (common.createReadme) { + if (common.createReadme || sessionStorage.createReadme) { var data = { driveReadme: Messages.driveReadme, driveReadmeTitle: Messages.driveReadmeTitle, @@ -2342,7 +2364,7 @@ define([ })); } }).nThen(function (waitFor) { - if (common.migrateAnonDrive) { + if (common.migrateAnonDrive || sessionStorage.migrateAnonDrive) { common.mergeAnonDrive(waitFor()); } }).nThen(function (waitFor) { diff --git a/www/common/sframe-common-outer.js b/www/common/sframe-common-outer.js index f1fd0ac8d..b7ce64d4d 100644 --- a/www/common/sframe-common-outer.js +++ b/www/common/sframe-common-outer.js @@ -124,7 +124,7 @@ define([ SFrameChannel.create(msgEv, postMsg, waitFor(function (sfc) { Utils.sframeChan = sframeChan = sfc; window.CryptPad_loadingError = function (e) { - sfc.event('EV_LOADING_ERROR', e) + sfc.event('EV_LOADING_ERROR', e); }; })); }); @@ -260,6 +260,11 @@ define([ } // Otherwise, continue } + // FIXME Backward compatibility + if (sessionStorage.newPadPassword && !newPadPassword) { + newPadPassword = sessionStorage.newPadPassword; + delete sessionStorage.newPadPassword; + } if (!parsed.hashData) { // No hash, no need to check for a password diff --git a/www/register/main.js b/www/register/main.js index 39069bd94..2bf9d9f39 100644 --- a/www/register/main.js +++ b/www/register/main.js @@ -39,7 +39,7 @@ define([ if (localStorage.login_user) { $uname.val(localStorage.login_user); - delete loginStorage.login_user; + delete localStorage.login_user; } [ $uname, $passwd, $confirm]