Refactor compact mode logic and enhance pinned tab URL handling (closes https://github.com/zen-browser/desktop/issues/7453#issuecomment-2794479221)

This commit is contained in:
mr. m
2025-04-10 19:23:38 +02:00
parent 286999599a
commit a0d3447202
4 changed files with 78 additions and 56 deletions

View File

@@ -386,8 +386,8 @@
await this._resetTabToStoredState(tab);
}
async replacePinnedUrlWithCurrent() {
const tab = TabContextMenu.contextTab;
async replacePinnedUrlWithCurrent(tab = undefined) {
tab ??= TabContextMenu.contextTab;
if (!tab || !tab.pinned || !tab.getAttribute('zen-pin-id')) {
return;
}
@@ -806,8 +806,11 @@
if (!pin) {
return;
}
// Remove # and ? from the url
const pinUrl = pin.url.split('#')[0].split('?')[0];
const currentUrl = browser.currentURI.spec.split('#')[0].split('?')[0];
// Add an indicator that the pin has been changed
if (pin.url === browser.currentURI.spec) {
if (pinUrl === currentUrl) {
this.resetPinChangedUrl(tab);
return;
}
@@ -967,6 +970,20 @@
indicator.style.removeProperty('top');
}
}
async onTabLabelChanged(tab) {
if (!this._pinsCache) {
return;
}
// If our current pin in the cache point to about:blank, we need to update the entry
const pin = this._pinsCache.find((pin) => pin.uuid === tab.getAttribute('zen-pin-id'));
if (!pin) {
return;
}
if (pin.url === 'about:blank') {
await this.replacePinnedUrlWithCurrent(tab);
}
}
}
window.gZenPinnedTabManager = new ZenPinnedTabManager();