updateIcon: use the old flow to avoid "no tab" errors
This commit is contained in:
parent
5a61ac2f18
commit
257fda4d1d
24
messaging.js
24
messaging.js
|
@ -97,13 +97,12 @@ function updateIcon(tab, styles) {
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
(isNTP ? getTabRealURL(tab) : Promise.resolve(tab.url))
|
if (isNTP) {
|
||||||
.then(url => getStylesSafe({
|
getTabRealURL(tab).then(url =>
|
||||||
matchUrl: url,
|
getStyles({matchUrl: url, enabled: true, asHash: true}, stylesReceived));
|
||||||
enabled: true,
|
} else {
|
||||||
asHash: true,
|
getStyles({matchUrl: tab.url, enabled: true, asHash: true}, stylesReceived);
|
||||||
}))
|
}
|
||||||
.then(stylesReceived);
|
|
||||||
|
|
||||||
function stylesReceived(styles) {
|
function stylesReceived(styles) {
|
||||||
let numStyles = styles.length;
|
let numStyles = styles.length;
|
||||||
|
@ -129,10 +128,13 @@ function updateIcon(tab, styles) {
|
||||||
38: `images/icon/38${postfix}.png`,
|
38: `images/icon/38${postfix}.png`,
|
||||||
// TODO: add Edge preferred sizes: 20, 25, 30, 40
|
// TODO: add Edge preferred sizes: 20, 25, 30, 40
|
||||||
},
|
},
|
||||||
}, ignoreChromeError);
|
}, () => {
|
||||||
// Vivaldi bug workaround: setBadgeText must follow setBadgeBackgroundColor
|
if (!chrome.runtime.lastError) {
|
||||||
chrome.browserAction.setBadgeBackgroundColor({color});
|
// Vivaldi bug workaround: setBadgeText must follow setBadgeBackgroundColor
|
||||||
chrome.browserAction.setBadgeText({text, tabId: tab.id});
|
chrome.browserAction.setBadgeBackgroundColor({color});
|
||||||
|
chrome.browserAction.setBadgeText({text, tabId: tab.id});
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user