From 98a9801644c857b619b2bb6edf240fb790639986 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 16 Aug 2019 18:25:13 +0300 Subject: [PATCH] feature(cloudcmd) add ability to remember position of current file on reload --- client/client.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/client/client.js b/client/client.js index f411cd39..503b4928 100644 --- a/client/client.js +++ b/client/client.js @@ -249,14 +249,22 @@ function CloudCmdProto(DOM) { } }; + async function saveCurrentName(currentName) { + await Storage.set('current-name', currentName); + } + async function baseInit() { const files = DOM.getFiles(); CloudCmd.on('current-file', DOM.updateCurrentInfo); + CloudCmd.on('current-name', saveCurrentName); + + const name = await Storage.get('current-name'); + const currentFile = name && DOM.getCurrentByName(name) || files[0]; /* выделяем строку с первым файлом */ if (files) - DOM.setCurrentFile(files[0], { + DOM.setCurrentFile(currentFile, { // when hash is present // it should be handled with this.route // overwre otherwise @@ -361,7 +369,6 @@ function CloudCmdProto(DOM) { if (!newObj) return; - /* eslint require-atomic-updates:0 */ options.sort = sort; options.order = order;