MessagePeek: add setting to hide muted dms and group chats (#797)
This commit is contained in:
parent
adcf725998
commit
ab533f84f8
1 changed files with 29 additions and 2 deletions
|
|
@ -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<ActivityTextProps> = 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 <Timestamp channel={channel} />;
|
||||
},
|
||||
|
||||
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 (
|
||||
<ActivityText
|
||||
user={user}
|
||||
activities={activities}
|
||||
voiceChannel={voiceChannel}
|
||||
applicationStream={applicationStream}
|
||||
/>
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
const lastMessage = MessageStore.getLastMessage(channel.id) as Message | undefined;
|
||||
const hasActivity = hasRelevantActivity({ activities, status, applicationStream, voiceChannel });
|
||||
const showActivity = shouldShowActivity(lastMessage, hasActivity);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue