mirror of
https://github.com/zen-browser/components.git
synced 2025-07-08 15:09:59 +02:00
Refactor tab navigation logic and add contextChangeContainerTab method
This commit is contained in:
parent
6ab00d24f8
commit
831801add3
1 changed files with 24 additions and 1 deletions
|
@ -20,6 +20,10 @@ var ZenWorkspaces = {
|
||||||
return Services.prefs.getBoolPref('zen.workspaces.enabled', false);
|
return Services.prefs.getBoolPref('zen.workspaces.enabled', false);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getActiveWorkspaceFromCache() {
|
||||||
|
return this._workspaceCache.workspaces.find((workspace) => workspace.used);
|
||||||
|
},
|
||||||
|
|
||||||
// Wrorkspaces saving/loading
|
// Wrorkspaces saving/loading
|
||||||
get _storeFile() {
|
get _storeFile() {
|
||||||
return PathUtils.join(PathUtils.profileDir, 'zen-workspaces', 'Workspaces.json');
|
return PathUtils.join(PathUtils.profileDir, 'zen-workspaces', 'Workspaces.json');
|
||||||
|
@ -96,7 +100,7 @@ var ZenWorkspaces = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_kIcons: ['🏠', '📄', '💹', '💼', '📧', '✅', '👥'],
|
_kIcons: JSON.parse(Services-prefs.getStringPref("zen.workspaces.icons", '["🌐", "📁", "📎", "📝", "📅", "📊"]')),
|
||||||
|
|
||||||
_initializeWorkspaceCreationIcons() {
|
_initializeWorkspaceCreationIcons() {
|
||||||
let container = document.getElementById('PanelUI-zen-workspaces-create-icons-container');
|
let container = document.getElementById('PanelUI-zen-workspaces-create-icons-container');
|
||||||
|
@ -575,6 +579,16 @@ var ZenWorkspaces = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
async contextChangeContainerTab(event) {
|
||||||
|
let workspaces = await this._workspaces();
|
||||||
|
let workspace = workspaces.workspaces.find((workspace) => workspace.uuid === this._contextMenuId);
|
||||||
|
let userContextId = parseInt(
|
||||||
|
event.target.getAttribute("data-usercontextid")
|
||||||
|
);
|
||||||
|
workspace.containerTabId = userContextId;
|
||||||
|
await this.saveWorkspace(workspace);
|
||||||
|
},
|
||||||
|
|
||||||
onContextMenuClose() {
|
onContextMenuClose() {
|
||||||
let target = document.querySelector(
|
let target = document.querySelector(
|
||||||
`#PanelUI-zen-workspaces [zen-workspace-id="${this._contextMenuId}"] .zen-workspace-actions`
|
`#PanelUI-zen-workspaces [zen-workspace-id="${this._contextMenuId}"] .zen-workspace-actions`
|
||||||
|
@ -643,6 +657,15 @@ var ZenWorkspaces = {
|
||||||
const workspaces = await this._workspaces();
|
const workspaces = await this._workspaces();
|
||||||
await this.changeWorkspace(workspaces.workspaces.find((workspace) => workspace.uuid === workspaceID));
|
await this.changeWorkspace(workspaces.workspaces.find((workspace) => workspace.uuid === workspaceID));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Tab browser utilities
|
||||||
|
getContextIdIfNeeded(userContextId) {
|
||||||
|
if (typeof userContextId !== "undefined" || !this.workspaceEnabled) {
|
||||||
|
return userContextId;
|
||||||
|
}
|
||||||
|
const activeWorkspace = this.getActiveWorkspaceFromCache();
|
||||||
|
return activeWorkspace?.containerTabId;
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
ZenWorkspaces.init();
|
ZenWorkspaces.init();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue