Add workspaces in localstorage

pull/1/head
Grandschtroumpf 5 years ago committed by François
parent 50b9b73aa4
commit 8cd5b7d1cb
  1. 8
      src/app.js
  2. 2
      src/lib/store.js
  3. 1
      src/remixAppManager.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') 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) const appManager = new RemixAppManager(appStore)
registry.put({api: appManager, name: 'appmanager'}) 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() ...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) framingService.start(appStore, sidePanel, verticalIcons, mainPanel, this._components.resizeFeature)
// The event listener needs to be registered as early as possible, because the // The event listener needs to be registered as early as possible, because the

@ -194,6 +194,7 @@ export class EntityStore extends Store {
* @param {((string|number))} ids An id or a list of id to activate * @param {((string|number))} ids An id or a list of id to activate
*/ */
activate (id) { activate (id) {
if (this.actives.includes(id)) return
this.state.actives.push(id) this.state.actives.push(id)
this.event.emit('activate', 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 * @param {(string|number))} ids An id or a list of id to deactivate
*/ */
deactivate (id) { deactivate (id) {
if (!this.actives.includes(id)) return
this.state.actives.splice(this.state.actives.indexOf(id), 1) this.state.actives.splice(this.state.actives.indexOf(id), 1)
this.event.emit('deactivate', id) this.event.emit('deactivate', id)
} }

@ -41,6 +41,7 @@ export class RemixAppManager extends AppManagerApi {
if (!isActive) { if (!isActive) {
this.removeHiddenServices(api) this.removeHiddenServices(api)
} }
localStorage.setItem('workspace', JSON.stringify(this.store.actives))
} }
getEntity (apiName) { getEntity (apiName) {

Loading…
Cancel
Save