From b32959126e506c886d45fad2abb48a66d0554e4c Mon Sep 17 00:00:00 2001 From: Andrew Grant Date: Wed, 13 Dec 2023 17:54:09 -0500 Subject: [PATCH] TypingIndicator: setting to disable for current channel (#2043) --- src/plugins/typingIndicator/index.tsx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/plugins/typingIndicator/index.tsx b/src/plugins/typingIndicator/index.tsx index c5cf5a9d0..171c560d8 100644 --- a/src/plugins/typingIndicator/index.tsx +++ b/src/plugins/typingIndicator/index.tsx @@ -21,7 +21,7 @@ import ErrorBoundary from "@components/ErrorBoundary"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; import { findExportedComponentLazy, findStoreLazy } from "@webpack"; -import { ChannelStore, GuildMemberStore, i18n, RelationshipStore, Tooltip, UserStore, useStateFromStores } from "@webpack/common"; +import { ChannelStore, GuildMemberStore, i18n, RelationshipStore, SelectedChannelStore, Tooltip, UserStore, useStateFromStores } from "@webpack/common"; import { buildSeveralUsers } from "../typingTweaks"; @@ -47,7 +47,7 @@ function TypingIndicator({ channelId }: { channelId: string; }) { return oldKeys.length === currentKeys.length && currentKeys.every(key => old[key] != null); } ); - + const currentChannelId: string = useStateFromStores([SelectedChannelStore], () => SelectedChannelStore.getChannelId()); const guildId = ChannelStore.getChannel(channelId).guild_id; if (!settings.store.includeMutedChannels) { @@ -55,6 +55,10 @@ function TypingIndicator({ channelId }: { channelId: string; }) { if (isChannelMuted) return null; } + if (!settings.store.includeCurrentChannel) { + if (currentChannelId === channelId) return null; + } + const myId = UserStore.getCurrentUser()?.id; const typingUsersArray = Object.keys(typingUsers).filter(id => id !== myId && !(RelationshipStore.isBlocked(id) && !settings.store.includeBlockedUsers)); @@ -101,6 +105,11 @@ function TypingIndicator({ channelId }: { channelId: string; }) { } const settings = definePluginSettings({ + includeCurrentChannel: { + type: OptionType.BOOLEAN, + description: "Whether to show the typing indicator for the currently selected channel", + default: true + }, includeMutedChannels: { type: OptionType.BOOLEAN, description: "Whether to show the typing indicator for muted channels.",