try to avoid setBadgeText errors
This commit is contained in:
parent
ceed8b565c
commit
fdc15d24d9
|
@ -16,6 +16,7 @@ globals:
|
||||||
URLS: false
|
URLS: false
|
||||||
BG: false
|
BG: false
|
||||||
notifyAllTabs: false
|
notifyAllTabs: false
|
||||||
|
getTab: false
|
||||||
getActiveTab: false
|
getActiveTab: false
|
||||||
getActiveTabRealURL: false
|
getActiveTabRealURL: false
|
||||||
getTabRealURL: false
|
getTabRealURL: false
|
||||||
|
|
|
@ -210,12 +210,7 @@ function updateIcon(tab, styles) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (styles) {
|
if (styles) {
|
||||||
// check for not-yet-existing tabs e.g. omnibox instant search
|
stylesReceived(styles);
|
||||||
chrome.tabs.get(tab.id, () => {
|
|
||||||
if (!chrome.runtime.lastError) {
|
|
||||||
stylesReceived(styles);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
getTabRealURL(tab).then(url =>
|
getTabRealURL(tab).then(url =>
|
||||||
|
@ -247,11 +242,14 @@ function updateIcon(tab, styles) {
|
||||||
// TODO: add Edge preferred sizes: 20, 25, 30, 40
|
// TODO: add Edge preferred sizes: 20, 25, 30, 40
|
||||||
},
|
},
|
||||||
}, () => {
|
}, () => {
|
||||||
if (!chrome.runtime.lastError) {
|
if (chrome.runtime.lastError) {
|
||||||
// Vivaldi bug workaround: setBadgeText must follow setBadgeBackgroundColor
|
return;
|
||||||
chrome.browserAction.setBadgeBackgroundColor({color});
|
|
||||||
chrome.browserAction.setBadgeText({text, tabId: tab.id});
|
|
||||||
}
|
}
|
||||||
|
// Vivaldi bug workaround: setBadgeText must follow setBadgeBackgroundColor
|
||||||
|
chrome.browserAction.setBadgeBackgroundColor({color});
|
||||||
|
getTab(tab.id).then(() => {
|
||||||
|
chrome.browserAction.setBadgeText({text, tabId: tab.id});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,6 +87,13 @@ function notifyAllTabs(msg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function getTab(id) {
|
||||||
|
return new Promise(resolve =>
|
||||||
|
chrome.tabs.get(id, tab =>
|
||||||
|
!chrome.runtime.lastError && resolve(tab)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function getActiveTab() {
|
function getActiveTab() {
|
||||||
return new Promise(resolve =>
|
return new Promise(resolve =>
|
||||||
chrome.tabs.query({currentWindow: true, active: true}, tabs =>
|
chrome.tabs.query({currentWindow: true, active: true}, tabs =>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user