mirror of
https://github.com/zen-browser/desktop.git
synced 2025-09-29 14:38:37 +00:00
Refactor Zen tab management to improve performance and enable conditional functionality
This commit is contained in:
@@ -184,8 +184,6 @@
|
||||
|
||||
#vertical-pinned-tabs-container {
|
||||
padding-inline-end: 0 !important;
|
||||
max-height: unset !important;
|
||||
overflow: visible !important;
|
||||
display: flex !important;
|
||||
flex-direction: column;
|
||||
|
||||
|
@@ -39,6 +39,9 @@
|
||||
class ZenPinnedTabManager extends ZenPreloadedFeature {
|
||||
|
||||
init() {
|
||||
if (!this.enabled) {
|
||||
return;
|
||||
}
|
||||
this.observer = new ZenPinnedTabsObserver();
|
||||
this._initClosePinnedTabShortcut();
|
||||
this._insertItemsIntoTabContextMenu();
|
||||
@@ -48,9 +51,23 @@
|
||||
}
|
||||
|
||||
async initTabs() {
|
||||
if (!this.enabled) {
|
||||
return;
|
||||
}
|
||||
await ZenPinnedTabsStorage.init();
|
||||
}
|
||||
|
||||
get enabled() {
|
||||
if (!this._enabled) {
|
||||
this._enabled = !(
|
||||
docElement.hasAttribute('privatebrowsingmode') ||
|
||||
docElement.getAttribute('chromehidden').includes('toolbar') ||
|
||||
docElement.getAttribute('chromehidden').includes('menubar')
|
||||
);
|
||||
}
|
||||
return this._enabled;
|
||||
}
|
||||
|
||||
async _refreshPinnedTabs() {
|
||||
await this._initializePinsCache();
|
||||
this._initializePinnedTabs();
|
||||
@@ -161,6 +178,7 @@
|
||||
}
|
||||
|
||||
_onPinnedTabEvent(action, event) {
|
||||
if (!this.enabled) return;
|
||||
const tab = event.target;
|
||||
switch (action) {
|
||||
case "TabPinned":
|
||||
@@ -449,6 +467,9 @@
|
||||
}
|
||||
|
||||
updatePinnedTabContextMenu(contextTab) {
|
||||
if (!this.enabled) {
|
||||
return;
|
||||
}
|
||||
const isVisible = contextTab.pinned && !contextTab.multiselected;
|
||||
document.getElementById("context_zen-reset-pinned-tab").hidden = !isVisible || !contextTab.getAttribute("zen-pin-id");
|
||||
document.getElementById("context_zen-replace-pinned-url-with-current").hidden = !isVisible;
|
||||
|
@@ -250,7 +250,7 @@
|
||||
|
||||
canUnloadTab(tab, currentTimestamp, excludedUrls, ignoreTimestamp = false) {
|
||||
if (
|
||||
tab.pinned ||
|
||||
(tab.pinned && !ignoreTimestamp) ||
|
||||
tab.selected ||
|
||||
tab.multiselected ||
|
||||
tab.hasAttribute('busy') ||
|
||||
@@ -259,9 +259,9 @@
|
||||
tab.splitView ||
|
||||
tab.attention ||
|
||||
tab.linkedBrowser?.zenModeActive ||
|
||||
tab.pictureinpicture ||
|
||||
tab.soundPlaying ||
|
||||
tab.zenIgnoreUnload ||
|
||||
(tab.pictureinpicture && !ignoreTimestamp) ||
|
||||
(tab.soundPlaying && !ignoreTimestamp) ||
|
||||
(tab.zenIgnoreUnload && !ignoreTimestamp) ||
|
||||
excludedUrls.some((url) => url.test(tab.linkedBrowser.currentURI.spec))
|
||||
) {
|
||||
return false;
|
||||
|
Reference in New Issue
Block a user