Skip to content

Commit

Permalink
feat: Include message requests in count
Browse files Browse the repository at this point in the history
  • Loading branch information
Covkie committed Jun 28, 2024
1 parent 6af88e0 commit d850a62
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/renderer/appBadge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,19 @@ import { Settings } from "./settings";

let GuildReadStateStore: any;
let NotificationSettingsStore: any;
let MessageRequestStore: any;

export function setBadge() {
if (Settings.store.appBadge === false) return;

try {
const mentionCount = GuildReadStateStore.getTotalMentionCount();
const pendingRequests = RelationshipStore.getPendingCount();
const messageRequests = MessageRequestStore.getMessageRequestsCount();
const hasUnread = GuildReadStateStore.hasAnyUnread();
const disableUnreadBadge = NotificationSettingsStore.getDisableUnreadBadge();

let totalCount = mentionCount + pendingRequests;
let totalCount = mentionCount + pendingRequests + messageRequests;
if (!totalCount && hasUnread && !disableUnreadBadge) totalCount = -1;

VesktopNative.app.setBadgeCount(totalCount);
Expand All @@ -44,4 +46,5 @@ function waitForAndSubscribeToStore(name: string, cb?: (m: any) => void) {

waitForAndSubscribeToStore("GuildReadStateStore", store => (GuildReadStateStore = store));
waitForAndSubscribeToStore("NotificationSettingsStore", store => (NotificationSettingsStore = store));
waitForAndSubscribeToStore("MessageRequestStore", store => (MessageRequestStore = store));
waitForAndSubscribeToStore("RelationshipStore");

0 comments on commit d850a62

Please sign in to comment.