diff --git a/src/plugins/readAllNotificationsButton/index.tsx b/src/plugins/readAllNotificationsButton/index.tsx index 3bf53f993d..7a6737a8a6 100644 --- a/src/plugins/readAllNotificationsButton/index.tsx +++ b/src/plugins/readAllNotificationsButton/index.tsx @@ -22,14 +22,34 @@ import { addServerListElement, removeServerListElement, ServerListRenderPosition import ErrorBoundary from "@components/ErrorBoundary"; import { Devs } from "@utils/constants"; import definePlugin from "@utils/types"; +import { findStoreLazy } from "@webpack"; import { Button, FluxDispatcher, GuildChannelStore, GuildStore, React, ReadStateStore } from "@webpack/common"; +import { Channel } from "discord-types/general"; + +interface ThreadJoined { + channel: Channel; + joinTimestamp: number; +} + +type ThreadsJoined = Record; +type ThreadsJoinedByParent = Record; + +interface ActiveJoinedThreadsStore { + getActiveJoinedThreadsForGuild(guildId: string): ThreadsJoinedByParent; +} + +const ActiveJoinedThreadsStore: ActiveJoinedThreadsStore = findStoreLazy("ActiveJoinedThreadsStore"); function onClick() { const channels: Array = []; Object.values(GuildStore.getGuilds()).forEach(guild => { - GuildChannelStore.getChannels(guild.id).SELECTABLE - .concat(GuildChannelStore.getChannels(guild.id).VOCAL) + GuildChannelStore.getChannels(guild.id).SELECTABLE // Array<{ channel, comparator }> + .concat(GuildChannelStore.getChannels(guild.id).VOCAL) // Array<{ channel, comparator }> + .concat( + Object.values(ActiveJoinedThreadsStore.getActiveJoinedThreadsForGuild(guild.id)) + .flatMap(threadChannels => Object.values(threadChannels)) + ) .forEach((c: { channel: { id: string; }; }) => { if (!ReadStateStore.hasUnread(c.channel.id)) return;