* Increases the badged by one.
(quiet = false, request)
| 27 | * Increases the badged by one. |
| 28 | */ |
| 29 | function increaseBadged(quiet = false, request) { |
| 30 | if (!quiet) increaseCleanedCounter(); |
| 31 | |
| 32 | if(request === null) return; |
| 33 | |
| 34 | const tabId = request.tabId; |
| 35 | const url = request.url; |
| 36 | |
| 37 | if(tabId === -1) return; |
| 38 | |
| 39 | if (badges[tabId] == null) { |
| 40 | badges[tabId] = { |
| 41 | counter: 1, |
| 42 | lastURL: url |
| 43 | }; |
| 44 | } else { |
| 45 | badges[tabId].counter += 1; |
| 46 | } |
| 47 | |
| 48 | checkOSAndroid().then((res) => { |
| 49 | if (!res) { |
| 50 | if (storage.badgedStatus && !quiet) { |
| 51 | browser.browserAction.setBadgeText({text: (badges[tabId]).counter.toString(), tabId: tabId}).catch(handleError); |
| 52 | } else { |
| 53 | browser.browserAction.setBadgeText({text: "", tabId: tabId}).catch(handleError); |
| 54 | } |
| 55 | } |
| 56 | }); |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * Call by each tab is updated. |
no test coverage detected