mirror of
https://github.com/zen-browser/components.git
synced 2025-07-08 15:39:58 +02:00
Merge pull request #41 from kristijanribaric/fix(workspaces-migration-sync)-make-sure-migrated-workspaces-are-synced
fix(workspaces): Migrate workspaces from JSON to the new storage after sync engine has been registered.
This commit is contained in:
commit
8213592bb2
2 changed files with 3 additions and 4 deletions
|
@ -21,6 +21,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
|
||||||
await ZenWorkspacesStorage.init();
|
await ZenWorkspacesStorage.init();
|
||||||
if(!Weave.Service.engineManager.get("workspaces")) {
|
if(!Weave.Service.engineManager.get("workspaces")) {
|
||||||
Weave.Service.engineManager.register(ZenWorkspacesEngine);
|
Weave.Service.engineManager.register(ZenWorkspacesEngine);
|
||||||
|
await ZenWorkspacesStorage.migrateWorkspacesFromJSON();
|
||||||
}
|
}
|
||||||
await this.initializeWorkspaces();
|
await this.initializeWorkspaces();
|
||||||
console.info('ZenWorkspaces: ZenWorkspaces initialized');
|
console.info('ZenWorkspaces: ZenWorkspaces initialized');
|
||||||
|
|
|
@ -29,18 +29,16 @@ var ZenWorkspacesStorage = {
|
||||||
)
|
)
|
||||||
`);
|
`);
|
||||||
});
|
});
|
||||||
|
|
||||||
await this._migrateWorkspacesFromJSON();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
async _migrateWorkspacesFromJSON() {
|
async migrateWorkspacesFromJSON() {
|
||||||
const oldWorkspacesPath = PathUtils.join(PathUtils.profileDir, 'zen-workspaces', 'Workspaces.json');
|
const oldWorkspacesPath = PathUtils.join(PathUtils.profileDir, 'zen-workspaces', 'Workspaces.json');
|
||||||
if (await IOUtils.exists(oldWorkspacesPath)) {
|
if (await IOUtils.exists(oldWorkspacesPath)) {
|
||||||
console.info('ZenWorkspacesStorage: Migrating workspaces from JSON...');
|
console.info('ZenWorkspacesStorage: Migrating workspaces from JSON...');
|
||||||
const oldWorkspaces = await IOUtils.readJSON(oldWorkspacesPath);
|
const oldWorkspaces = await IOUtils.readJSON(oldWorkspacesPath);
|
||||||
if (oldWorkspaces.workspaces) {
|
if (oldWorkspaces.workspaces) {
|
||||||
for (const workspace of oldWorkspaces.workspaces) {
|
for (const workspace of oldWorkspaces.workspaces) {
|
||||||
await this.saveWorkspace(workspace, false); // Disable immediate notification
|
await this.saveWorkspace(workspace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await IOUtils.remove(oldWorkspacesPath);
|
await IOUtils.remove(oldWorkspacesPath);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue