From 3df077bdab356fc42ff6673156c8f65e02741cc9 Mon Sep 17 00:00:00 2001 From: Jake <134332787+justjxke@users.noreply.github.com> Date: Sun, 29 Mar 2026 17:10:09 +0100 Subject: [PATCH] fix: Fix bookmarked/tab new forum posts not showing unread count (#944) --- .../channelTabs/components/ChannelTab.tsx | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/equicordplugins/channelTabs/components/ChannelTab.tsx b/src/equicordplugins/channelTabs/components/ChannelTab.tsx index 7b953b028..567f48e9d 100644 --- a/src/equicordplugins/channelTabs/components/ChannelTab.tsx +++ b/src/equicordplugins/channelTabs/components/ChannelTab.tsx @@ -13,7 +13,7 @@ import { getGuildAcronym, getIntlMessage, getUniqueUsername } from "@utils/disco import { classes } from "@utils/misc"; import { Channel, Guild, User } from "@vencord/discord-types"; import { findComponentByCodeLazy, findCssClassesLazy } from "@webpack"; -import { Avatar, ChannelStore, ContextMenuApi, GuildStore, PresenceStore, ReadStateStore, ThemeStore, TypingStore, useDrag, useDrop, useEffect, useRef, UserStore, useState, useStateFromStores } from "@webpack/common"; +import { ActiveJoinedThreadsStore, Avatar, ChannelStore, ContextMenuApi, GuildStore, PresenceStore, ReadStateStore, ThemeStore, TypingStore, useDrag, useDrop, useEffect, useRef, UserStore, useState, useStateFromStores } from "@webpack/common"; import { JSX } from "react"; import { TabContextMenu } from "./ContextMenus"; @@ -75,19 +75,29 @@ function TypingIndicator({ isTyping }: { isTyping: boolean; }) { : null; } +function getChannelUnreadState(channelId: string) { + const channel = ChannelStore.getChannel(channelId); + const newForumPostCount = channel?.guild_id && channel.isForumLikeChannel?.() + ? ActiveJoinedThreadsStore.getNewThreadCount(channel.guild_id, channel.id) + : 0; + const unreadCount = ReadStateStore.getUnreadCount(channelId) || newForumPostCount; + + return { + channelId, + hasUnread: ReadStateStore.hasUnread(channelId) || newForumPostCount > 0, + mentionCount: ReadStateStore.getMentionCount(channelId), + unreadCount + }; +} + export const NotificationDot = ({ channelIds }: { channelIds: string[]; }) => { const userId = UserStore.getCurrentUser()?.id; const { persistUnreadCountFallback } = settings.use(["persistUnreadCountFallback"]); const [, forceUpdate] = useState(0); const channelStateKey = channelIds.join(","); const channelStates = useStateFromStores( - [ReadStateStore], - () => channelIds.map(channelId => ({ - channelId, - hasUnread: ReadStateStore.hasUnread(channelId), - mentionCount: ReadStateStore.getMentionCount(channelId), - unreadCount: ReadStateStore.getUnreadCount(channelId) - })) + [ActiveJoinedThreadsStore, ReadStateStore], + () => channelIds.map(getChannelUnreadState) ); const stateSignature = channelStates.map(state => `${state.channelId}:${Number(state.hasUnread)}:${state.mentionCount}:${state.unreadCount}`).join("|"); const { badgeText, hasMention, shouldShow } = getNotificationDotState(