This commit is contained in:
Mr. M
2025-04-29 10:08:09 +02:00
3 changed files with 51 additions and 12 deletions

View File

@@ -83,8 +83,23 @@
onTabIconChanged(tab, url = null) {
const iconUrl = url ?? tab.iconImage.src;
if (tab.hasAttribute('zen-essential')) {
tab.querySelector('.tab-background').style.setProperty('--zen-tab-icon', `url(${iconUrl})`);
if (!iconUrl) {
try {
setTimeout(() => {
PlacesUtils.favicons.getFaviconURLForPage(
tab.linkedBrowser.currentURI,
(url) => {
if (url) gBrowser.setIcon(tab, url.spec);
},
0
);
});
} catch {}
} else {
if (tab.hasAttribute('zen-essential')) {
tab.querySelector('.tab-background').style.setProperty('--zen-tab-icon', `url(${iconUrl})`);
}
}
// TODO: work on this
//if (tab.hasAttribute('zen-pinned-changed') || !this._pinsCache) {

View File

@@ -68,10 +68,9 @@
async function setCachedFaviconForURL(pageUrl, iconURL) {
try {
// TODO: This always return "NS_ERROR_NOT_AVAILABLE" for some reason, figure out why
await PlacesUtils.favicons.setFaviconForPage(
Services.io.newURI(pageUrl),
Services.io.newURI('fake-favicon-uri:' + pageUrl),
Services.io.newURI(iconURL),
Services.io.newURI(iconURL)
);
} catch (ex) {
@@ -84,6 +83,18 @@
['https://reddit.com/r/zen_browser', 'Zen on Reddit', 'https://private-cdn.zen-browser.app/reddit.png'],
['https://x.com/zen_browser', 'Zen on Twitter', 'https://private-cdn.zen-browser.app/x.png'],
];
await PlacesUtils.history.insertMany(
tabs.map((site) => ({
url: site[0],
visits: [
{
transition: PlacesUtils.history.TRANSITIONS.TYPED,
},
],
}))
);
for (const site of tabs) {
const tab = window.gBrowser.addTrustedTab(site[0], {
inBackground: true,
@@ -443,6 +454,18 @@
const selectedTabs = document
.getElementById('zen-welcome-initial-essentials-browser-sidebar-essentials')
.querySelectorAll('.tabbrowser-tab[visuallyselected]');
await PlacesUtils.history.insertMany(
[...selectedTabs].map((tab) => ({
url: tab.getAttribute('data-url'),
visits: [
{
transition: PlacesUtils.history.TRANSITIONS.TYPED,
},
],
}))
);
for (const tab of selectedTabs) {
const url = tab.getAttribute('data-url');
const createdTab = window.gBrowser.addTrustedTab(url, {

View File

@@ -684,10 +684,10 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
}
getActiveWorkspaceFromCache() {
return this.getWoekspaceFromId(this.activeWorkspace);
return this.getWorkspaceFromId(this.activeWorkspace);
}
getWoekspaceFromId(id) {
getWorkspaceFromId(id) {
try {
return this._workspaceCache.workspaces.find((workspace) => workspace.uuid === id);
} catch (e) {
@@ -710,7 +710,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
const activeWorkspaceId = this.activeWorkspace;
if (activeWorkspaceId) {
const activeWorkspace = this.getWoekspaceFromId(activeWorkspaceId);
const activeWorkspace = this.getWorkspaceFromId(activeWorkspaceId);
// Set the active workspace ID to the first one if the one with selected id doesn't exist
if (!activeWorkspace) {
this.activeWorkspace = this._workspaceCache.workspaces[0]?.uuid;
@@ -2384,7 +2384,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
const workspaceIndicator = document.querySelector(
`#zen-current-workspace-indicator-container .zen-workspace-tabs-section[zen-workspace-id="${workspaceId}"]`
);
const workspaceObject = this.getWoekspaceFromId(workspaceId);
const workspaceObject = this.getWorkspaceFromId(workspaceId);
const essentialContainer = this.getEssentialsSection(workspaceObject.containerTabId);
this._updateMarginTopPinnedTabs(arrowScrollbox, pinnedContainer, essentialContainer, workspaceIndicator, forAnimation);
this.updateShouldHideSeparator(arrowScrollbox, pinnedContainer);
@@ -2405,7 +2405,8 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
if (tab.hasAttribute('change-workspace') && this.moveTabToWorkspace(tab, workspaceID)) {
this._lastSelectedWorkspaceTabs[workspaceID] = gZenGlanceManager.getTabOrGlanceParent(tab);
tab.removeAttribute('change-workspace');
await this.changeWorkspace({ uuid: workspaceID, containerTabId: tab.getAttribute('usercontextid') }, { onInit: true });
const workspace = this.getWorkspaceFromId(workspaceID);
await this.changeWorkspace(workspace);
}
return;
}
@@ -2449,7 +2450,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
// Switch workspace if needed
if (workspaceID && workspaceID !== activeWorkspace.uuid && this._hasInitializedTabsStrip) {
const workspaceToChange = this.getWoekspaceFromId(workspaceID);
const workspaceToChange = this.getWorkspaceFromId(workspaceID);
await this.changeWorkspace(workspaceToChange);
}
}
@@ -2634,7 +2635,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
// Tab browser utilities
createContainerTabMenu(event) {
let window = event.target.ownerGlobal;
const workspace = this.getWoekspaceFromId(this._contextMenuId);
const workspace = this.getWorkspaceFromId(this._contextMenuId);
let containerTabId = workspace.containerTabId;
return window.createUserContextMenu(event, {
isContextMenu: true,
@@ -2831,7 +2832,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
(workspace) => workspace.containerTabId + 0 === containerTabId
);
} else {
workspaceToSwitch = this.getWoekspaceFromId(tab.getAttribute('zen-workspace-id'));
workspaceToSwitch = this.getWorkspaceFromId(tab.getAttribute('zen-workspace-id'));
}
if (!workspaceToSwitch) {
console.error('No workspace found for tab, cannot switch');