diff --git a/src/app.js b/src/app.js index e2bcd19005..7716329e61 100644 --- a/src/app.js +++ b/src/app.js @@ -264,6 +264,8 @@ Please make a backup of your contracts and start using http://remix.ethereum.org } let appStore = new EntityStore('module', 'name') + // Get workspace before creating the App Manager + const workspace = JSON.parse(localStorage.getItem('workspace')) const appManager = new RemixAppManager(appStore) registry.put({api: appManager, name: 'appmanager'}) @@ -439,6 +441,12 @@ Please make a backup of your contracts and start using http://remix.ethereum.org ...appManager.plugins() ]) + // Set workspace after initial activation + if (Array.isArray(workspace)) { + console.log(workspace) + appManager.activateMany(workspace) + } + framingService.start(appStore, sidePanel, verticalIcons, mainPanel, this._components.resizeFeature) // The event listener needs to be registered as early as possible, because the diff --git a/src/lib/store.js b/src/lib/store.js index e9b699d516..acd86162f2 100644 --- a/src/lib/store.js +++ b/src/lib/store.js @@ -194,6 +194,7 @@ export class EntityStore extends Store { * @param {((string|number))} ids An id or a list of id to activate */ activate (id) { + if (this.actives.includes(id)) return this.state.actives.push(id) this.event.emit('activate', id) } @@ -203,6 +204,7 @@ export class EntityStore extends Store { * @param {(string|number))} ids An id or a list of id to deactivate */ deactivate (id) { + if (!this.actives.includes(id)) return this.state.actives.splice(this.state.actives.indexOf(id), 1) this.event.emit('deactivate', id) } diff --git a/src/remixAppManager.js b/src/remixAppManager.js index 73c620e3ce..07580d5ef7 100644 --- a/src/remixAppManager.js +++ b/src/remixAppManager.js @@ -41,6 +41,7 @@ export class RemixAppManager extends AppManagerApi { if (!isActive) { this.removeHiddenServices(api) } + localStorage.setItem('workspace', JSON.stringify(this.store.actives)) } getEntity (apiName) {