TypingIndicator: setting to disable for current channel (#2043)

This commit is contained in:
Andrew Grant 2023-12-13 17:54:09 -05:00 committed by GitHub
parent 2cf52d0775
commit b32959126e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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.",