Skip to content

Commit

Permalink
show "unread" notification on non-"inbox" folders too, #656
Browse files Browse the repository at this point in the history
* It worked for "local store" mode, but now show works without "local store" mode enabling too.
  • Loading branch information
vladimiry committed Apr 20, 2024
1 parent 7763c5c commit 0669911
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/electron-preload/webview/primary/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,15 @@ export function registerApi(providerApi: ProviderApi): void {
(() => {
const isEventsApiUrl = providerApi._custom_.buildEventsApiUrlTester({entryApiUrl});
const isMessagesCountApiUrl = providerApi._custom_.buildMessagesCountApiUrlTester({entryApiUrl});
const excludeLabelIdsFromUnreadCalculation = ((excludeIds: string[]) => {
return (labelID: string) => excludeIds.includes(labelID);
})([
SYSTEM_FOLDER_IDENTIFIERS.Archive,
SYSTEM_FOLDER_IDENTIFIERS.Spam,
SYSTEM_FOLDER_IDENTIFIERS.Trash,
SYSTEM_FOLDER_IDENTIFIERS["All Mail"],
SYSTEM_FOLDER_IDENTIFIERS["Almost All Mail"],
]);
const responseListeners = [
{
tester: {test: isMessagesCountApiUrl},
Expand All @@ -373,7 +382,7 @@ export function registerApi(providerApi: ProviderApi): void {
return;
}
return Counts
.filter(({LabelID}) => LabelID === SYSTEM_FOLDER_IDENTIFIERS.Inbox)
.filter(({LabelID}) => !excludeLabelIdsFromUnreadCalculation(LabelID))
.reduce((accumulator, item) => accumulator + item.Unread, 0);
},
},
Expand All @@ -384,7 +393,7 @@ export function registerApi(providerApi: ProviderApi): void {
return;
}
return MessageCounts
.filter(({LabelID}) => LabelID === SYSTEM_FOLDER_IDENTIFIERS.Inbox)
.filter(({LabelID}) => !excludeLabelIdsFromUnreadCalculation(LabelID))
.reduce((accumulator, item) => accumulator + item.Unread, 0);
},
},
Expand Down

0 comments on commit 0669911

Please sign in to comment.