Skip to content

Commit

Permalink
Update core.js - Badge counter >999 (#285)
Browse files Browse the repository at this point in the history
* Update core.js - Badge counter

Since the browser chrome is only wide enough for 3 chars, update the counter so that unreadfeeds count of >999 will show as "1k+"

* Improve setBadgeCounter function

---------

Co-authored-by: Oleg Shevchenko <[email protected]>
  • Loading branch information
thereddestdog and olsh authored Sep 4, 2024
1 parent 8b5329c commit 0da06b8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/scripts/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,12 @@ function updateSavedFeeds() {
/* Sets badge counter if unread feeds more than zero */
function setBadgeCounter(unreadFeedsCount) {
if (appGlobal.options.showCounter) {
chrome.browserAction.setBadgeText({ text: String(+unreadFeedsCount > 0 ? unreadFeedsCount : "")});
const unreadFeedsCountNumber = +unreadFeedsCount;
if (unreadFeedsCountNumber > 999) {
const thousands = Math.floor(unreadFeedsCountNumber / 1000);
unreadFeedsCount = thousands + "k+";
}
chrome.browserAction.setBadgeText({ text: String(unreadFeedsCountNumber > 0 ? unreadFeedsCount : "")});
} else {
chrome.browserAction.setBadgeText({ text: ""});
}
Expand Down

0 comments on commit 0da06b8

Please sign in to comment.