Skip to content

Commit

Permalink
fix: indicator doesn't update after mask as read (#154)
Browse files Browse the repository at this point in the history
  • Loading branch information
tjx666 authored Aug 16, 2024
1 parent 44e529f commit 7b35659
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions source/github-notifications-preview.css
Original file line number Diff line number Diff line change
Expand Up @@ -206,3 +206,7 @@
#AppHeader-notifications-button {
z-index: 81;
}

#AppHeader-notifications-button > svg::before {
display: var(--notifications-icon-indicator-display, "block");
}
10 changes: 9 additions & 1 deletion source/github-notifications-preview.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,18 @@ function isOpen(element) {
return elementExists('.NPG-container[open], .NPG-loading', element);
}

function updateNotificationsIndicatorStatus(show) {
$('#AppHeader-notifications-button > svg').style.setProperty(
'--notifications-icon-indicator-display',
show ? 'block' : 'none',
);
}

async function updateUnreadCount() {
const latestStatusElement = $('.notification-indicator .mail-status', await notifications.dom);
const latestCount = $('.js-notification-inboxes .selected .count', await notifications.dom).textContent;
const latestCount = $('.js-notification-inboxes .selected .count', await notifications.dom)?.textContent ?? '';
const rghCount = getRefinedGitHubUnreadCount();
updateNotificationsIndicatorStatus(latestCount && (Number(latestCount) + rghCount > 0));

for (const statusElement of $$('.notification-indicator .mail-status')) {
if (options.previewCount && statusElement.textContent !== latestCount) {
Expand Down

0 comments on commit 7b35659

Please sign in to comment.