Skip to content

Commit

Permalink
added ability to change icon to unread
Browse files Browse the repository at this point in the history
  • Loading branch information
PolisanTheEasyNick committed Apr 18, 2024
1 parent a63028f commit 3ccb0c4
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/main/mainWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { isTruthy } from "shared/utils/guards";
import { once } from "shared/utils/once";
import type { SettingsStore } from "shared/utils/SettingsStore";

import { DEAFENED_ICON_PATH, ICON_PATH, IDLE_ICON_PATH, MUTED_ICON_PATH, SPEAKING_ICON_PATH } from "../shared/paths";
import { DEAFENED_ICON_PATH, ICON_PATH, IDLE_ICON_PATH, MUTED_ICON_PATH, SPEAKING_ICON_PATH, UNREAD_ICON_PATH } from "shared/paths";
import { createAboutWindow } from "./about";
import { initArRPC } from "./arrpc";
import {
Expand Down Expand Up @@ -491,6 +491,9 @@ export async function setTrayIcon(iconName) {
case "deafened":
tray.setImage(DEAFENED_ICON_PATH);
break;
case "unread":
tray.setImage(UNREAD_ICON_PATH);
break;
case "idle":
tray.setImage(IDLE_ICON_PATH);
break;
Expand Down
7 changes: 6 additions & 1 deletion src/renderer/appBadge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { filters, waitFor } from "@vencord/types/webpack";
import { RelationshipStore } from "@vencord/types/webpack/common";

import { Settings } from "./settings";
import { isInVC } from "./patches/tray";

let GuildReadStateStore: any;
let NotificationSettingsStore: any;
Expand All @@ -23,8 +24,12 @@ export function setBadge() {

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

VesktopNative.app.setBadgeCount(totalCount);
if(totalCount > 0 && !isInVC) {
VesktopNative.app.setTrayIcon("unread");
} else if (!isInVC) {
VesktopNative.app.setTrayIcon("main");
}
} catch (e) {
console.error(e);
}
Expand Down
4 changes: 4 additions & 0 deletions src/renderer/patches/tray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { FluxDispatcher, UserStore } from "@vencord/types/webpack/common";
const muteActions = findByPropsLazy("isSelfMute");
const deafActions = findByPropsLazy("isSelfDeaf");

export var isInVC = false;

onceReady.then(() => {
const userID = UserStore.getCurrentUser().id;

Expand Down Expand Up @@ -49,6 +51,7 @@ onceReady.then(() => {

FluxDispatcher.subscribe("RTC_CONNECTION_STATE", params => {
if (params.state === "RTC_CONNECTED") {
isInVC = true;
if (deafActions.isSelfDeaf()) {
VesktopNative.app.setTrayIcon("deafened");
} else if (muteActions.isSelfMute()) {
Expand All @@ -57,6 +60,7 @@ onceReady.then(() => {
VesktopNative.app.setTrayIcon("idle");
}
} else if (params.state === "RTC_DISCONNECTED") {
isInVC = false;
VesktopNative.app.setTrayIcon("main");
}
});
Expand Down
1 change: 1 addition & 0 deletions src/shared/paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ export const SPEAKING_ICON_PATH = /* @__PURE__ */ join(STATIC_DIR, "speaking.png
export const MUTED_ICON_PATH = /* @__PURE__ */ join(STATIC_DIR, "muted.png");
export const DEAFENED_ICON_PATH = /* @__PURE__ */ join(STATIC_DIR, "deafened.png");
export const IDLE_ICON_PATH = /* @__PURE__ */ join(STATIC_DIR, "idle.png");
export const UNREAD_ICON_PATH = /* @__PURE__ */ join(STATIC_DIR, "unread.png");
Binary file added static/unread.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 3ccb0c4

Please sign in to comment.