From 9ee62925652323036af341b68683c1fd057afa1d Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Sat, 20 Oct 2018 10:10:34 +0200 Subject: [PATCH] hot-reload: save editor state, history, and sidepanel state --- src/browser/js/app/ipc/callbacks.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/browser/js/app/ipc/callbacks.js b/src/browser/js/app/ipc/callbacks.js index 0e904b6d..3c7629c1 100644 --- a/src/browser/js/app/ipc/callbacks.js +++ b/src/browser/js/app/ipc/callbacks.js @@ -5,6 +5,8 @@ var utils = require('../ui/utils'), state = require('../managers/state'), editor = require('../editor/'), locales = require('../locales'), + {deepCopy} = require('../utils'), + sidepanel = require('../ui/sidepanel'), ipc = require('./') module.exports = { @@ -110,7 +112,11 @@ module.exports = { ipc.send('storeBackup', { backupId: id, session: session.session, - state: state.get() + state: state.get(), + history: editor.history, + historyState: editor.historyState, + editorEnabled: editor.enabled, + sidepanelOpened: document.getElementById('sidepanel').classList.contains('sidepanel-open') }) // reload page and hold backup id @@ -135,6 +141,11 @@ module.exports = { session.load(data.session, ()=>{ state.set(data.state, false) + editor.historySession = deepCopy(data.session) + editor.history = data.history + editor.historyState = data.historyState + if (data.sidepanelOpened) sidepanel.open() + if (data.editorEnabled) editor.enable() }) }