diff --git a/src/equicordplugins/messagePeek/index.tsx b/src/equicordplugins/messagePeek/index.tsx index 9e28bca9c..fd63f9f97 100644 --- a/src/equicordplugins/messagePeek/index.tsx +++ b/src/equicordplugins/messagePeek/index.tsx @@ -8,16 +8,17 @@ import "./style.css"; import { DecoratorProps } from "@api/MemberListDecorators"; import { isPluginEnabled } from "@api/PluginManager"; +import { definePluginSettings } from "@api/Settings"; import betterActivities from "@equicordplugins/betterActivities"; import showMeYourName from "@plugins/showMeYourName"; import { Devs, EquicordDevs } from "@utils/constants"; import { classNameFactory } from "@utils/css"; import { classes } from "@utils/misc"; -import definePlugin from "@utils/types"; +import definePlugin, { OptionType } from "@utils/types"; import { Activity, ApplicationStream, Channel, Message, OnlineStatus, User } from "@vencord/discord-types"; import { MessageFlags } from "@vencord/discord-types/enums"; import { findByCodeLazy, findByPropsLazy, findComponentByCodeLazy, findCssClassesLazy, findExportedComponentLazy } from "@webpack"; -import { ChannelStore, ExperimentStore, MessageStore, Parser, RelationshipStore, SnowflakeUtils, UserStore, useStateFromStores } from "@webpack/common"; +import { ChannelStore, ExperimentStore, MessageStore, Parser, RelationshipStore, SnowflakeUtils, UserGuildSettingsStore, UserStore, useStateFromStores } from "@webpack/common"; const cl = classNameFactory("vc-message-peek-"); @@ -30,6 +31,14 @@ const ActivityText: React.ComponentType = findComponentByCode const ONE_HOUR_MS = 60 * 60 * 1000; +const settings = definePluginSettings({ + hideMuted: { + type: OptionType.BOOLEAN, + description: "Hide message previews and timestamps for muted DMs and group chats.", + default: false + } +}); + type AttachmentType = "image" | "gif" | "video" | "file"; type IconType = AttachmentType | "voice" | "sticker"; @@ -231,6 +240,7 @@ export default definePlugin({ name: "MessagePeek", description: "Shows the last message preview and timestamp in the Direct Messages list.", authors: [Devs.prism, EquicordDevs.justjxke], + settings, patches: [ { find: "PrivateChannel.renderAvatar", @@ -252,11 +262,28 @@ export default definePlugin({ renderMemberListDecorator({ channel }: DecoratorProps) { if (!channel) return null; + if (settings.store.hideMuted && UserGuildSettingsStore.isChannelMuted(null!, channel.id)) return null; return ; }, getSubText(props: PrivateChannelProps) { const { channel, user, activities, status, applicationStream, voiceChannel } = props; + + if (settings.store.hideMuted && UserGuildSettingsStore.isChannelMuted(null!, channel.id)) { + const hasActivity = hasRelevantActivity({ activities, status, applicationStream, voiceChannel }); + if (hasActivity) { + return ( + + ); + } + return null; + } + const lastMessage = MessageStore.getLastMessage(channel.id) as Message | undefined; const hasActivity = hasRelevantActivity({ activities, status, applicationStream, voiceChannel }); const showActivity = shouldShowActivity(lastMessage, hasActivity);