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) {
|
onTabIconChanged(tab, url = null) {
|
||||||
const iconUrl = url ?? tab.iconImage.src;
|
const iconUrl = url ?? tab.iconImage.src;
|
||||||
if (!iconUrl) {
|
if (!iconUrl && tab.hasAttribute('zen-pin-id')) {
|
||||||
try {
|
try {
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
try {
|
try {
|
||||||
|
await this.promisePinnedCacheInitialized;
|
||||||
const pin = this._pinsCache?.find(
|
const pin = this._pinsCache?.find(
|
||||||
(pin) => pin.uuid === tab.getAttribute('zen-pin-id')
|
(pin) => pin.uuid === tab.getAttribute('zen-pin-id')
|
||||||
);
|
);
|
||||||
|
@ -162,6 +163,9 @@
|
||||||
await gZenWorkspaces.promiseSectionsInitialized;
|
await gZenWorkspaces.promiseSectionsInitialized;
|
||||||
await this._initializePinsCache();
|
await this._initializePinsCache();
|
||||||
await this._initializePinnedTabs(init);
|
await this._initializePinnedTabs(init);
|
||||||
|
if (init) {
|
||||||
|
this._resolveInitializedPinnedCache();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async _initializePinsCache() {
|
async _initializePinsCache() {
|
||||||
|
@ -637,17 +641,12 @@
|
||||||
this.resetPinChangedUrl(tab);
|
this.resetPinChangedUrl(tab);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getFaviconAsBase64(pageUrl, secondTry = false) {
|
async getFaviconAsBase64(pageUrl) {
|
||||||
try {
|
try {
|
||||||
const faviconData = await PlacesUtils.favicons.getFaviconForPage(pageUrl);
|
const faviconData = await PlacesUtils.favicons.getFaviconForPage(pageUrl);
|
||||||
if (!faviconData) {
|
if (!faviconData) {
|
||||||
if (secondTry || pageUrl.spec.startsWith('about:')) {
|
// empty favicon
|
||||||
// empty favicon
|
return 'data:image/png;base64,';
|
||||||
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;
|
return faviconData.dataURI;
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
|
@ -1135,4 +1134,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
window.gZenPinnedTabManager = new ZenPinnedTabManager();
|
window.gZenPinnedTabManager = new ZenPinnedTabManager();
|
||||||
|
|
||||||
|
gZenPinnedTabManager.promisePinnedCacheInitialized = new Promise((resolve) => {
|
||||||
|
gZenPinnedTabManager._resolveInitializedPinnedCache = resolve;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue