Refactor ZenWorkspaces to use async/await for shortcutSwitchTo method

This commit is contained in:
mauro-balades 2024-09-23 17:00:20 +02:00
parent b4b3c1f0d4
commit a97e7e65ed
2 changed files with 325 additions and 208 deletions

View file

@ -833,5 +833,12 @@ var ZenWorkspaces = {
}
return [activeWorkspaceUserContextId, true];
},
async shortcutSwitchTo(index) {
const workspaces = await this._workspaces();
// The index may be out of bounds, so we need to wrap it around
const workspaceToSwitch = workspaces.workspaces[(index + workspaces.workspaces.length) % workspaces.workspaces.length];
await this.changeWorkspace(workspaceToSwitch);
}
};