Skip to content

Commit

Permalink
Add workspaces in localstorage
Browse files Browse the repository at this point in the history
  • Loading branch information
GrandSchtroumpf committed Jul 1, 2019
1 parent 50b9b73 commit 8cd5b7d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'})

Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/lib/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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)
}
Expand Down
1 change: 1 addition & 0 deletions src/remixAppManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export class RemixAppManager extends AppManagerApi {
if (!isActive) {
this.removeHiddenServices(api)
}
localStorage.setItem('workspace', JSON.stringify(this.store.actives))
}

getEntity (apiName) {
Expand Down

0 comments on commit 8cd5b7d

Please sign in to comment.