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 {
|
#vertical-pinned-tabs-container {
|
||||||
padding-inline-end: 0 !important;
|
padding-inline-end: 0 !important;
|
||||||
max-height: unset !important;
|
|
||||||
overflow: visible !important;
|
|
||||||
display: flex !important;
|
display: flex !important;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
||||||
|
@@ -39,6 +39,9 @@
|
|||||||
class ZenPinnedTabManager extends ZenPreloadedFeature {
|
class ZenPinnedTabManager extends ZenPreloadedFeature {
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
|
if (!this.enabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.observer = new ZenPinnedTabsObserver();
|
this.observer = new ZenPinnedTabsObserver();
|
||||||
this._initClosePinnedTabShortcut();
|
this._initClosePinnedTabShortcut();
|
||||||
this._insertItemsIntoTabContextMenu();
|
this._insertItemsIntoTabContextMenu();
|
||||||
@@ -48,9 +51,23 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
async initTabs() {
|
async initTabs() {
|
||||||
|
if (!this.enabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
await ZenPinnedTabsStorage.init();
|
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() {
|
async _refreshPinnedTabs() {
|
||||||
await this._initializePinsCache();
|
await this._initializePinsCache();
|
||||||
this._initializePinnedTabs();
|
this._initializePinnedTabs();
|
||||||
@@ -161,6 +178,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
_onPinnedTabEvent(action, event) {
|
_onPinnedTabEvent(action, event) {
|
||||||
|
if (!this.enabled) return;
|
||||||
const tab = event.target;
|
const tab = event.target;
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case "TabPinned":
|
case "TabPinned":
|
||||||
@@ -449,6 +467,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
updatePinnedTabContextMenu(contextTab) {
|
updatePinnedTabContextMenu(contextTab) {
|
||||||
|
if (!this.enabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const isVisible = contextTab.pinned && !contextTab.multiselected;
|
const isVisible = contextTab.pinned && !contextTab.multiselected;
|
||||||
document.getElementById("context_zen-reset-pinned-tab").hidden = !isVisible || !contextTab.getAttribute("zen-pin-id");
|
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;
|
document.getElementById("context_zen-replace-pinned-url-with-current").hidden = !isVisible;
|
||||||
|
@@ -250,7 +250,7 @@
|
|||||||
|
|
||||||
canUnloadTab(tab, currentTimestamp, excludedUrls, ignoreTimestamp = false) {
|
canUnloadTab(tab, currentTimestamp, excludedUrls, ignoreTimestamp = false) {
|
||||||
if (
|
if (
|
||||||
tab.pinned ||
|
(tab.pinned && !ignoreTimestamp) ||
|
||||||
tab.selected ||
|
tab.selected ||
|
||||||
tab.multiselected ||
|
tab.multiselected ||
|
||||||
tab.hasAttribute('busy') ||
|
tab.hasAttribute('busy') ||
|
||||||
@@ -259,9 +259,9 @@
|
|||||||
tab.splitView ||
|
tab.splitView ||
|
||||||
tab.attention ||
|
tab.attention ||
|
||||||
tab.linkedBrowser?.zenModeActive ||
|
tab.linkedBrowser?.zenModeActive ||
|
||||||
tab.pictureinpicture ||
|
(tab.pictureinpicture && !ignoreTimestamp) ||
|
||||||
tab.soundPlaying ||
|
(tab.soundPlaying && !ignoreTimestamp) ||
|
||||||
tab.zenIgnoreUnload ||
|
(tab.zenIgnoreUnload && !ignoreTimestamp) ||
|
||||||
excludedUrls.some((url) => url.test(tab.linkedBrowser.currentURI.spec))
|
excludedUrls.some((url) => url.test(tab.linkedBrowser.currentURI.spec))
|
||||||
) {
|
) {
|
||||||
return false;
|
return false;
|
||||||
|
Reference in New Issue
Block a user