forked from ZenBrowserMirrors/zen-desktop
fix: Fixed pinned tab icons not appearing at startup, b=(no-bug), c=tabs
This commit is contained in:
parent
5c6e5f7361
commit
18944d5ed8
1 changed files with 12 additions and 9 deletions
|
@ -90,10 +90,11 @@
|
|||
|
||||
onTabIconChanged(tab, url = null) {
|
||||
const iconUrl = url ?? tab.iconImage.src;
|
||||
if (!iconUrl) {
|
||||
if (!iconUrl && tab.hasAttribute('zen-pin-id')) {
|
||||
try {
|
||||
setTimeout(async () => {
|
||||
try {
|
||||
await this.promisePinnedCacheInitialized;
|
||||
const pin = this._pinsCache?.find(
|
||||
(pin) => pin.uuid === tab.getAttribute('zen-pin-id')
|
||||
);
|
||||
|
@ -162,6 +163,9 @@
|
|||
await gZenWorkspaces.promiseSectionsInitialized;
|
||||
await this._initializePinsCache();
|
||||
await this._initializePinnedTabs(init);
|
||||
if (init) {
|
||||
this._resolveInitializedPinnedCache();
|
||||
}
|
||||
}
|
||||
|
||||
async _initializePinsCache() {
|
||||
|
@ -637,18 +641,13 @@
|
|||
this.resetPinChangedUrl(tab);
|
||||
}
|
||||
|
||||
async getFaviconAsBase64(pageUrl, secondTry = false) {
|
||||
async getFaviconAsBase64(pageUrl) {
|
||||
try {
|
||||
const faviconData = await PlacesUtils.favicons.getFaviconForPage(pageUrl);
|
||||
if (!faviconData) {
|
||||
if (secondTry || pageUrl.spec.startsWith('about:')) {
|
||||
// empty favicon
|
||||
return 'data:image/png;base64,';
|
||||
}
|
||||
// Try again with the domain
|
||||
const domainUrl = pageUrl.spec.substring(0, pageUrl.spec.indexOf('/'));
|
||||
return await this.getFaviconAsBase64(Services.io.newURI(domainUrl), true);
|
||||
}
|
||||
return faviconData.dataURI;
|
||||
} catch (ex) {
|
||||
console.error('Failed to get favicon:', ex);
|
||||
|
@ -1135,4 +1134,8 @@
|
|||
}
|
||||
|
||||
window.gZenPinnedTabManager = new ZenPinnedTabManager();
|
||||
|
||||
gZenPinnedTabManager.promisePinnedCacheInitialized = new Promise((resolve) => {
|
||||
gZenPinnedTabManager._resolveInitializedPinnedCache = resolve;
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue