From 1ad1b78c640915d372db4e5898ae17330d04a77c Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 19 Jun 2017 14:41:31 +0200 Subject: [PATCH] Fix the history mode with readOnly and old URLs --- www/common/common-history.js | 12 ++++++++++++ www/drive/main.js | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/www/common/common-history.js b/www/common/common-history.js index 48b210eb3..e75a192c1 100644 --- a/www/common/common-history.js +++ b/www/common/common-history.js @@ -37,6 +37,17 @@ define([ var parsed = config.href ? common.parsePadUrl(config.href) : {}; var secret = common.getSecrets(parsed.type, parsed.hash); + + History.readOnly = 1; + if (!secret.keys) { + secret.keys = secret.key; + History.readOnly = 2; + } + else if (!secret.keys.validateKey) { + secret.keys.validateKey = true; + History.readOnly = 0; + } + var crypto = Crypto.createEncryptor(secret.keys); var to = window.setTimeout(function () { @@ -185,6 +196,7 @@ define([ 'class':'revertHistory buttonSuccess', title: Messages.history_restoreTitle }).text(Messages.history_restore).appendTo($nav); + if (!History.readOnly) { $rev.hide(); } onUpdate = function () { $cur.attr('max', states.length); diff --git a/www/drive/main.js b/www/drive/main.js index 5e3e6b589..88fe7a0fd 100644 --- a/www/drive/main.js +++ b/www/drive/main.js @@ -1783,6 +1783,7 @@ define([ module.hideMenu(); if (!APP.editable) { debug("Read-only mode"); } if (!appStatus.isReady && !force) { return; } + // Only Trash and Root are available in not-owned files manager if (displayedCategories.indexOf(path[0]) === -1) { log(Messages.categoryError); @@ -1816,7 +1817,6 @@ define([ if (!isSearch) { delete APP.Search.oldLocation; } module.resetTree(); - if (displayedCategories.indexOf(SEARCH) !== -1 && $tree.find('#searchInput').length) { // in history mode we want to focus the version number input if (!history.isHistoryMode && !APP.mobile()) { @@ -2539,6 +2539,7 @@ define([ history.onEnterHistory = function (obj) { var files = obj.drive; filesOp = FO.init(files, config); + appStatus.isReady = true; refresh(); }; history.onLeaveHistory = function () {