feat: Include message requests in count
This commit is contained in:
parent
6af88e0432
commit
d850a62794
1 changed files with 4 additions and 1 deletions
|
@ -11,6 +11,7 @@ import { Settings } from "./settings";
|
||||||
|
|
||||||
let GuildReadStateStore: any;
|
let GuildReadStateStore: any;
|
||||||
let NotificationSettingsStore: any;
|
let NotificationSettingsStore: any;
|
||||||
|
let MessageRequestStore: any;
|
||||||
|
|
||||||
export function setBadge() {
|
export function setBadge() {
|
||||||
if (Settings.store.appBadge === false) return;
|
if (Settings.store.appBadge === false) return;
|
||||||
|
@ -18,10 +19,11 @@ export function setBadge() {
|
||||||
try {
|
try {
|
||||||
const mentionCount = GuildReadStateStore.getTotalMentionCount();
|
const mentionCount = GuildReadStateStore.getTotalMentionCount();
|
||||||
const pendingRequests = RelationshipStore.getPendingCount();
|
const pendingRequests = RelationshipStore.getPendingCount();
|
||||||
|
const messageRequests = MessageRequestStore.getMessageRequestsCount();
|
||||||
const hasUnread = GuildReadStateStore.hasAnyUnread();
|
const hasUnread = GuildReadStateStore.hasAnyUnread();
|
||||||
const disableUnreadBadge = NotificationSettingsStore.getDisableUnreadBadge();
|
const disableUnreadBadge = NotificationSettingsStore.getDisableUnreadBadge();
|
||||||
|
|
||||||
let totalCount = mentionCount + pendingRequests;
|
let totalCount = mentionCount + pendingRequests + messageRequests;
|
||||||
if (!totalCount && hasUnread && !disableUnreadBadge) totalCount = -1;
|
if (!totalCount && hasUnread && !disableUnreadBadge) totalCount = -1;
|
||||||
|
|
||||||
VesktopNative.app.setBadgeCount(totalCount);
|
VesktopNative.app.setBadgeCount(totalCount);
|
||||||
|
@ -44,4 +46,5 @@ function waitForAndSubscribeToStore(name: string, cb?: (m: any) => void) {
|
||||||
|
|
||||||
waitForAndSubscribeToStore("GuildReadStateStore", store => (GuildReadStateStore = store));
|
waitForAndSubscribeToStore("GuildReadStateStore", store => (GuildReadStateStore = store));
|
||||||
waitForAndSubscribeToStore("NotificationSettingsStore", store => (NotificationSettingsStore = store));
|
waitForAndSubscribeToStore("NotificationSettingsStore", store => (NotificationSettingsStore = store));
|
||||||
|
waitForAndSubscribeToStore("MessageRequestStore", store => (MessageRequestStore = store));
|
||||||
waitForAndSubscribeToStore("RelationshipStore");
|
waitForAndSubscribeToStore("RelationshipStore");
|
||||||
|
|
Loading…
Reference in a new issue