mirror of
https://github.com/zen-browser/desktop.git
synced 2025-09-05 19:08:18 +00:00
fix: Fixed compact mode not restoring correctly at startup, b=bug #8606, c=compact-mode
This commit is contained in:
@@ -32,6 +32,9 @@
|
||||
- name: zen.view.compact.show-background-tab-toast
|
||||
value: true
|
||||
|
||||
- name: zen.view.compact.debug
|
||||
value: false
|
||||
|
||||
# Do not edit manually
|
||||
- name: zen.view.compact.should-enable-at-startup
|
||||
hidden: true
|
||||
|
@@ -39,16 +39,22 @@ var gZenCompactModeManager = {
|
||||
preInit() {
|
||||
// Remove it before initializing so we can properly calculate the width
|
||||
// of the sidebar at startup and avoid overflowing items not being hidden
|
||||
let xulStoreValue = Services.xulStore.getValue(
|
||||
AppConstants.BROWSER_CHROME_URL,
|
||||
'zen-main-app-wrapper',
|
||||
'zen-compact-mode'
|
||||
);
|
||||
if (xulStoreValue === '-moz-missing\n' || !xulStoreValue) {
|
||||
xulStoreValue = false;
|
||||
}
|
||||
this._wasInCompactMode =
|
||||
Services.xulStore.getValue(
|
||||
AppConstants.BROWSER_CHROME_URL,
|
||||
'zen-main-app-wrapper',
|
||||
'zen-compact-mode'
|
||||
) || Services.prefs.getBoolPref('zen.view.compact.should-enable-at-startup', false);
|
||||
xulStoreValue ||
|
||||
Services.prefs.getBoolPref('zen.view.compact.should-enable-at-startup', false);
|
||||
lazyCompactMode.mainAppWrapper.removeAttribute('zen-compact-mode');
|
||||
|
||||
this._canDebugLog = Services.prefs.getBoolPref('zen.view.compact.debug', false);
|
||||
|
||||
this.addContextMenu();
|
||||
this._resolvePreInit();
|
||||
},
|
||||
|
||||
init() {
|
||||
@@ -88,25 +94,30 @@ var gZenCompactModeManager = {
|
||||
});
|
||||
}
|
||||
|
||||
this._preInitPromise.then(() => {
|
||||
SessionStore.promiseAllWindowsRestored.then(() => {
|
||||
this.preference = this._wasInCompactMode;
|
||||
delete this._resolvePreInit;
|
||||
delete this._preInitPromise;
|
||||
});
|
||||
},
|
||||
|
||||
log(...args) {
|
||||
if (this._canDebugLog) {
|
||||
console.log('[Zen Compact Mode]', ...args);
|
||||
}
|
||||
},
|
||||
|
||||
get preference() {
|
||||
return lazyCompactMode.mainAppWrapper.getAttribute('zen-compact-mode') === 'true';
|
||||
return document.documentElement.getAttribute('zen-compact-mode') === 'true';
|
||||
},
|
||||
|
||||
get shouldBeCompact() {
|
||||
return !document.documentElement.getAttribute('chromehidden').includes('toolbar');
|
||||
return !document.documentElement.getAttribute('chromehidden')?.includes('toolbar');
|
||||
},
|
||||
|
||||
set preference(value) {
|
||||
if (!this.shouldBeCompact) {
|
||||
value = false;
|
||||
}
|
||||
this.log('Setting compact mode preference to', value);
|
||||
if (
|
||||
this.preference === value ||
|
||||
document.documentElement.hasAttribute('zen-compact-animating')
|
||||
@@ -225,6 +236,7 @@ var gZenCompactModeManager = {
|
||||
},
|
||||
|
||||
async _updateEvent() {
|
||||
const isUrlbarFocused = gURLBar.focused;
|
||||
// IF we are animating IN, call the callbacks first so we can calculate the width
|
||||
// once the window buttons are shown
|
||||
this.updateContextMenu();
|
||||
@@ -241,6 +253,9 @@ var gZenCompactModeManager = {
|
||||
this._evenListeners.forEach((callback) => callback());
|
||||
}
|
||||
gZenUIManager.updateTabsToolbar();
|
||||
if (isUrlbarFocused) {
|
||||
gURLBar.focus();
|
||||
}
|
||||
},
|
||||
|
||||
// NOTE: Dont actually use event, it's just so we make sure
|
||||
@@ -717,10 +732,6 @@ var gZenCompactModeManager = {
|
||||
},
|
||||
};
|
||||
|
||||
gZenCompactModeManager._preInitPromise = new Promise((resolve) => {
|
||||
gZenCompactModeManager._resolvePreInit = resolve;
|
||||
});
|
||||
|
||||
document.addEventListener(
|
||||
'MozBeforeInitialXULLayout',
|
||||
() => {
|
||||
|
Reference in New Issue
Block a user