updateIcon: use the old flow to avoid "no tab" errors

This commit is contained in:
tophf 2017-04-11 06:51:32 +03:00
parent 5a61ac2f18
commit 257fda4d1d

View File

@ -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});
}
});
} }
} }