mirror of
https://github.com/zen-browser/desktop.git
synced 2026-09-10 07:15:34 +00:00
gh-15297: Fixed synced tabs losing their icon when they are unloaded (gh-15298)
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
<command id="cmd_zenSplitViewUnsplit" />
|
||||
<command id="cmd_zenSplitViewLinkInNewTab" />
|
||||
<command id="cmd_zenSplitViewContextMenu" />
|
||||
<command id="cmd_zenCtxShareSplitView" />
|
||||
<command id="cmd_zenNewEmptySplit" />
|
||||
|
||||
<!-- Workspace commands -->
|
||||
|
||||
@@ -41,6 +41,9 @@ document.addEventListener(
|
||||
case "cmd_zenSplitViewContextMenu":
|
||||
gZenViewSplitter.contextSplitTabs();
|
||||
break;
|
||||
case "cmd_zenCtxShareSplitView":
|
||||
gZenViewSplitter.contextShareSplitView();
|
||||
break;
|
||||
case "cmd_zenCopyCurrentURLMarkdown":
|
||||
gZenCommonActions.copyCurrentURLAsMarkdownToClipboard();
|
||||
break;
|
||||
|
||||
@@ -24,7 +24,15 @@ const FOLDER_ICON_RE = /^chrome:\/\//;
|
||||
*/
|
||||
class nsZenShareManager extends nsZenDOMOperatedFeature {
|
||||
init() {
|
||||
this.#insertSplitViewMenuItem();
|
||||
if (!this.enabled) {
|
||||
for (const id of [
|
||||
"context_zenShareWorkspace",
|
||||
"context_zenShareFolder",
|
||||
]) {
|
||||
document.getElementById(id)?.setAttribute("hidden", "true");
|
||||
}
|
||||
return;
|
||||
}
|
||||
delayedStartupPromise.then(() => {
|
||||
gBrowser.addTabsProgressListener({
|
||||
onLocationChange: (browser, webProgress, request, aLocation) => {
|
||||
@@ -34,6 +42,10 @@ class nsZenShareManager extends nsZenDOMOperatedFeature {
|
||||
});
|
||||
}
|
||||
|
||||
get enabled() {
|
||||
return !gZenWorkspaces.privateWindowOrDisabled;
|
||||
}
|
||||
|
||||
// Mark: sharing
|
||||
|
||||
async shareSpace(workspaceId) {
|
||||
@@ -93,6 +105,9 @@ class nsZenShareManager extends nsZenDOMOperatedFeature {
|
||||
}
|
||||
|
||||
async #createAndCopyLink(item) {
|
||||
if (!this.enabled) {
|
||||
return;
|
||||
}
|
||||
if (!(await this.#confirmShare())) {
|
||||
return;
|
||||
}
|
||||
@@ -801,37 +816,6 @@ class nsZenShareManager extends nsZenDOMOperatedFeature {
|
||||
}
|
||||
return tab;
|
||||
}
|
||||
|
||||
// Mark: split view context menu
|
||||
|
||||
#insertSplitViewMenuItem() {
|
||||
const fragment = window.MozXULElement.parseXULToFragment(`
|
||||
<menuitem id="context_zenShareSplitView"
|
||||
data-lazy-l10n-id="zen-share-split-view"
|
||||
hidden="true"/>
|
||||
`);
|
||||
document.getElementById("context_moveTabToSplitView").before(fragment);
|
||||
const menuItem = document.getElementById("context_zenShareSplitView");
|
||||
menuItem.addEventListener("command", () => {
|
||||
const group = TabContextMenu.contextTab?.group;
|
||||
if (group?.hasAttribute("split-view-group")) {
|
||||
this.shareSplitView(group);
|
||||
}
|
||||
});
|
||||
document
|
||||
.getElementById("tabContextMenu")
|
||||
.addEventListener("popupshowing", () => {
|
||||
const contextTab = TabContextMenu.contextTab;
|
||||
const selectedTabs = contextTab?.multiselected
|
||||
? gBrowser.selectedTabs
|
||||
: [contextTab];
|
||||
menuItem.hidden =
|
||||
!contextTab ||
|
||||
!selectedTabs.every(tab =>
|
||||
tab?.group?.hasAttribute("split-view-group")
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
window.gZenShareManager = new nsZenShareManager();
|
||||
|
||||
@@ -1184,6 +1184,8 @@ class nsZenViewSplitter extends nsZenDOMOperatedFeature {
|
||||
document.l10n.setAttributes(splitTabCommand, "tab-zen-split-tabs", {
|
||||
tabCount: isExistingSplitView ? -1 : selectedTabs.length,
|
||||
});
|
||||
document.getElementById("context_zenShareSplitView").hidden =
|
||||
!gZenShareManager.enabled || !isExistingSplitView;
|
||||
if (isExistingSplitView) {
|
||||
splitTabCommand.removeAttribute("hidden");
|
||||
return;
|
||||
@@ -1204,6 +1206,10 @@ class nsZenViewSplitter extends nsZenDOMOperatedFeature {
|
||||
data-lazy-l10n-id="tab-zen-split-tabs"
|
||||
data-l10n-args='{"tabCount": 1}'
|
||||
command="cmd_zenSplitViewContextMenu"/>
|
||||
<menuitem id="context_zenShareSplitView"
|
||||
data-lazy-l10n-id="zen-share-split-view"
|
||||
hidden="true"
|
||||
command="cmd_zenCtxShareSplitView"/>
|
||||
`);
|
||||
document.getElementById("context_moveTabToSplitView").before(element);
|
||||
}
|
||||
@@ -1252,6 +1258,16 @@ class nsZenViewSplitter extends nsZenDOMOperatedFeature {
|
||||
this.splitTabs([currentTab, newTab], undefined, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shares the split view of the context tab.
|
||||
*/
|
||||
contextShareSplitView() {
|
||||
const group = TabContextMenu.contextTab?.group;
|
||||
if (group?.hasAttribute("split-view-group")) {
|
||||
gZenShareManager.shareSplitView(group);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Splits the selected tabs.
|
||||
*
|
||||
|
||||
@@ -654,7 +654,7 @@ class nsZenSpacesSyncApplier {
|
||||
);
|
||||
win.gBrowser.setIcon(tab, icon);
|
||||
lazy.TabStateCache.update(tab.linkedBrowser.permanentKey, {
|
||||
image: null,
|
||||
image: icon || null,
|
||||
});
|
||||
} catch (e) {
|
||||
console.error("ZenSpacesSync: failed to set tab icon", e);
|
||||
|
||||
@@ -680,7 +680,7 @@ class nsZenPinnedTabManager extends nsZenDOMOperatedFeature {
|
||||
}
|
||||
gBrowser.setIcon(tab, icon);
|
||||
lazy.TabStateCache.update(tab.permanentKey, {
|
||||
image: null,
|
||||
image: icon || null,
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user