mirror of
https://github.com/zen-browser/components.git
synced 2025-07-08 16:19:58 +02:00
Fixed workspaces not rendering properly
This commit is contained in:
parent
6031981acd
commit
2d43df747d
1 changed files with 21 additions and 15 deletions
|
@ -11,7 +11,6 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
|
||||||
return; // We are in a hidden window, don't initialize ZenWorkspaces
|
return; // We are in a hidden window, don't initialize ZenWorkspaces
|
||||||
}
|
}
|
||||||
this.ownerWindow = window;
|
this.ownerWindow = window;
|
||||||
console.info('ZenWorkspaces: Initializing ZenWorkspaces...');
|
|
||||||
XPCOMUtils.defineLazyPreferenceGetter(
|
XPCOMUtils.defineLazyPreferenceGetter(
|
||||||
this,
|
this,
|
||||||
'shouldShowIconStrip',
|
'shouldShowIconStrip',
|
||||||
|
@ -26,6 +25,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
ChromeUtils.defineLazyGetter(this, 'tabContainer', () => document.getElementById('tabbrowser-tabs'));
|
ChromeUtils.defineLazyGetter(this, 'tabContainer', () => document.getElementById('tabbrowser-tabs'));
|
||||||
|
this._activeWorkspace = Services.prefs.getStringPref('zen.workspaces.active', '');
|
||||||
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);
|
||||||
|
@ -38,6 +38,15 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
|
||||||
Services.obs.addObserver(this, "weave:engine:sync:finish");
|
Services.obs.addObserver(this, "weave:engine:sync:finish");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get activeWorkspace() {
|
||||||
|
return this._activeWorkspace;
|
||||||
|
}
|
||||||
|
|
||||||
|
set activeWorkspace(value) {
|
||||||
|
this._activeWorkspace = value;
|
||||||
|
Services.prefs.setStringPref('zen.workspaces.active', value);
|
||||||
|
}
|
||||||
|
|
||||||
async observe(subject, topic, data) {
|
async observe(subject, topic, data) {
|
||||||
if (topic === "weave:engine:sync:finish" && data === "workspaces") {
|
if (topic === "weave:engine:sync:finish" && data === "workspaces") {
|
||||||
try {
|
try {
|
||||||
|
@ -76,8 +85,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
|
||||||
|
|
||||||
getActiveWorkspaceFromCache() {
|
getActiveWorkspaceFromCache() {
|
||||||
try {
|
try {
|
||||||
const activeWorkspaceId = Services.prefs.getStringPref('zen.workspaces.active', '');
|
return this._workspaceCache.workspaces.find((workspace) => workspace.uuid === this.activeWorkspace);
|
||||||
return this._workspaceCache.workspaces.find((workspace) => workspace.uuid === activeWorkspaceId);
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -95,17 +103,17 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
|
||||||
|
|
||||||
this._workspaceCache = { workspaces, lastChangeTimestamp };
|
this._workspaceCache = { workspaces, lastChangeTimestamp };
|
||||||
// Get the active workspace ID from preferences
|
// Get the active workspace ID from preferences
|
||||||
const activeWorkspaceId = Services.prefs.getStringPref('zen.workspaces.active', '');
|
const activeWorkspaceId = this.activeWorkspace;
|
||||||
|
|
||||||
if (activeWorkspaceId) {
|
if (activeWorkspaceId) {
|
||||||
const activeWorkspace = this._workspaceCache.workspaces.find((w) => w.uuid === activeWorkspaceId);
|
const activeWorkspace = this._workspaceCache.workspaces.find((w) => w.uuid === activeWorkspaceId);
|
||||||
// Set the active workspace ID to the first one if the one with selected id doesn't exist
|
// Set the active workspace ID to the first one if the one with selected id doesn't exist
|
||||||
if (!activeWorkspace) {
|
if (!activeWorkspace) {
|
||||||
Services.prefs.setStringPref('zen.workspaces.active', this._workspaceCache.workspaces[0]?.uuid);
|
this.activeWorkspace = this._workspaceCache.workspaces[0]?.uuid;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Set the active workspace ID to the first one if active workspace doesn't exist
|
// Set the active workspace ID to the first one if active workspace doesn't exist
|
||||||
Services.prefs.setStringPref('zen.workspaces.active', this._workspaceCache.workspaces[0]?.uuid);
|
this.activeWorkspace = this._workspaceCache.workspaces[0]?.uuid;
|
||||||
}
|
}
|
||||||
// sort by position
|
// sort by position
|
||||||
this._workspaceCache.workspaces.sort((a, b) => (a.position ?? Infinity) - (b.position ?? Infinity));
|
this._workspaceCache.workspaces.sort((a, b) => (a.position ?? Infinity) - (b.position ?? Infinity));
|
||||||
|
@ -142,11 +150,11 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
|
||||||
let activeWorkspace = await this.getActiveWorkspace();
|
let activeWorkspace = await this.getActiveWorkspace();
|
||||||
if (!activeWorkspace) {
|
if (!activeWorkspace) {
|
||||||
activeWorkspace = workspaces.workspaces.find((workspace) => workspace.default);
|
activeWorkspace = workspaces.workspaces.find((workspace) => workspace.default);
|
||||||
Services.prefs.setStringPref('zen.workspaces.active', activeWorkspace.uuid);
|
this.activeWorkspace = activeWorkspace.uuid;
|
||||||
}
|
}
|
||||||
if (!activeWorkspace) {
|
if (!activeWorkspace) {
|
||||||
activeWorkspace = workspaces.workspaces[0];
|
activeWorkspace = workspaces.workspaces[0];
|
||||||
Services.prefs.setStringPref('zen.workspaces.active', activeWorkspace.uuid);
|
this.activeWorkspace = activeWorkspace.uuid;
|
||||||
}
|
}
|
||||||
await SessionStore.promiseInitialized;
|
await SessionStore.promiseInitialized;
|
||||||
await this.changeWorkspace(activeWorkspace, true);
|
await this.changeWorkspace(activeWorkspace, true);
|
||||||
|
@ -234,14 +242,12 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
|
||||||
}
|
}
|
||||||
|
|
||||||
isWorkspaceActive(workspace) {
|
isWorkspaceActive(workspace) {
|
||||||
const activeWorkspaceId = Services.prefs.getStringPref('zen.workspaces.active', '');
|
return workspace.uuid === this.activeWorkspace;
|
||||||
return workspace.uuid === activeWorkspaceId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async getActiveWorkspace() {
|
async getActiveWorkspace() {
|
||||||
const workspaces = await this._workspaces();
|
const workspaces = await this._workspaces();
|
||||||
const activeWorkspaceId = Services.prefs.getStringPref('zen.workspaces.active', '');
|
return workspaces.workspaces.find((workspace) => workspace.uuid === this.activeWorkspace) ?? workspaces.workspaces[0];
|
||||||
return workspaces.workspaces.find((workspace) => workspace.uuid === activeWorkspaceId);
|
|
||||||
}
|
}
|
||||||
// Workspaces dialog UI management
|
// Workspaces dialog UI management
|
||||||
|
|
||||||
|
@ -365,7 +371,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
|
||||||
};
|
};
|
||||||
browser.ZenWorkspaces._workspaceCache = null;
|
browser.ZenWorkspaces._workspaceCache = null;
|
||||||
let workspaces = await browser.ZenWorkspaces._workspaces();
|
let workspaces = await browser.ZenWorkspaces._workspaces();
|
||||||
let activeWorkspace = await this.getActiveWorkspace();
|
let activeWorkspace = await browser.ZenWorkspaces.getActiveWorkspace();
|
||||||
currentContainer.innerHTML = '';
|
currentContainer.innerHTML = '';
|
||||||
workspaceList.innerHTML = '';
|
workspaceList.innerHTML = '';
|
||||||
workspaceList.parentNode.style.display = 'flex';
|
workspaceList.parentNode.style.display = 'flex';
|
||||||
|
@ -380,7 +386,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
|
||||||
currentContainer.appendChild(currentWorkspace);
|
currentContainer.appendChild(currentWorkspace);
|
||||||
}
|
}
|
||||||
for (let workspace of workspaces.workspaces) {
|
for (let workspace of workspaces.workspaces) {
|
||||||
if (this.isWorkspaceActive(workspace)) {
|
if (browser.ZenWorkspaces.isWorkspaceActive(workspace)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let workspaceElement = createWorkspaceElement(workspace);
|
let workspaceElement = createWorkspaceElement(workspace);
|
||||||
|
@ -623,7 +629,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
|
||||||
}
|
}
|
||||||
|
|
||||||
this._inChangingWorkspace = true;
|
this._inChangingWorkspace = true;
|
||||||
Services.prefs.setStringPref('zen.workspaces.active', window.uuid);
|
this.activeWorkspace = window.uuid;
|
||||||
|
|
||||||
const shouldAllowPinnedTabs = this._shouldAllowPinTab;
|
const shouldAllowPinnedTabs = this._shouldAllowPinTab;
|
||||||
this.tabContainer._invalidateCachedTabs();
|
this.tabContainer._invalidateCachedTabs();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue