From 847a32765fb244087955de42a9fba33261524374 Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Sun, 1 Dec 2024 05:57:28 -0500 Subject: [PATCH] feat(shc): Add feature parity, more styles & show modes Co-authored-by: JustOptimize --- src/plugins/showHiddenChannels/index.tsx | 92 ++++++++++++++++++------ src/utils/constants.ts | 6 +- 2 files changed, 74 insertions(+), 24 deletions(-) diff --git a/src/plugins/showHiddenChannels/index.tsx b/src/plugins/showHiddenChannels/index.tsx index 6b67aee8..a23276ff 100644 --- a/src/plugins/showHiddenChannels/index.tsx +++ b/src/plugins/showHiddenChannels/index.tsx @@ -20,7 +20,7 @@ import "./style.css"; import { definePluginSettings } from "@api/Settings"; import ErrorBoundary from "@components/ErrorBoundary"; -import { Devs } from "@utils/constants"; +import { Devs, EquicordDevs } from "@utils/constants"; import { canonicalizeMatch } from "@utils/patches"; import definePlugin, { OptionType } from "@utils/types"; import { findByPropsLazy } from "@webpack"; @@ -33,24 +33,38 @@ const ChannelListClasses = findByPropsLazy("modeMuted", "modeSelected", "unread" const enum ShowMode { LockIcon, - HiddenIconWithMutedStyle + LockIconRight, + EyeIconRight, +} + +const enum ChannelStyle { + Classic, + Muted, + Unread, + MutedUnread, } const CONNECT = 1n << 20n; export const settings = definePluginSettings({ - hideUnreads: { - description: "Hide Unreads", - type: OptionType.BOOLEAN, - default: true, + channelStyle: { + description: "The style used to display hidden channels.", + type: OptionType.SELECT, + options: [ + { label: "Classic", value: ChannelStyle.Classic, default: true }, + { label: "Muted", value: ChannelStyle.Muted }, + { label: "Show Unreads", value: ChannelStyle.Unread }, + { label: "Muted and Show Unreads", value: ChannelStyle.MutedUnread } + ], restartNeeded: true }, showMode: { description: "The mode used to display hidden channels.", type: OptionType.SELECT, options: [ - { label: "Plain style with Lock Icon instead", value: ShowMode.LockIcon, default: true }, - { label: "Muted style with hidden eye icon on the right", value: ShowMode.HiddenIconWithMutedStyle }, + { label: "Lock Icon replacing channel icon", value: ShowMode.LockIcon, default: true }, + { label: "Eye icon on the right", value: ShowMode.EyeIconRight }, + { label: "Lock icon on the right", value: ShowMode.LockIconRight } ], restartNeeded: true }, @@ -68,7 +82,7 @@ function isUncategorized(objChannel: { channel: Channel; comparator: number; }) export default definePlugin({ name: "ShowHiddenChannels", description: "Show channels that you do not have access to view.", - authors: [Devs.BigDuck, Devs.AverageReactEnjoyer, Devs.D3SOX, Devs.Ven, Devs.Nuckyz, Devs.Nickyux, Devs.dzshn], + authors: [Devs.BigDuck, Devs.AverageReactEnjoyer, Devs.D3SOX, Devs.Ven, Devs.Nuckyz, Devs.Nickyux, Devs.dzshn, EquicordDevs.Oggetto], settings, patches: [ @@ -159,37 +173,50 @@ export default definePlugin({ }, { find: "UNREAD_IMPORTANT:", - predicate: () => settings.store.showMode === ShowMode.HiddenIconWithMutedStyle, + predicate: () => settings.store.showMode !== ShowMode.LockIcon, + replacement: [ + // Add the hidden eye icon if the channel is hidden + { + predicate: () => settings.store.showMode === ShowMode.EyeIconRight, + match: /\.name\),.{0,120}\.children.+?:null(?<=,channel:(\i).+?)/, + replace: (m, channel) => `${m},$self.isHiddenChannel(${channel})?$self.EyeRightIcon():null` + }, + // Add the hidden lock icon if the channel is hidden + { + predicate: () => settings.store.showMode === ShowMode.LockIconRight, + match: /\.name\),.{0,120}\.children.+?:null(?<=,channel:(\i).+?)/, + replace: (m, channel) => `${m},$self.isHiddenChannel(${channel})?$self.LockRightIcon():null` + }, + ] + }, + { + find: "UNREAD_IMPORTANT:", + predicate: () => settings.store.channelStyle === ChannelStyle.Muted || settings.store.channelStyle === ChannelStyle.MutedUnread, replacement: [ // Make the channel appear as muted if it's hidden { match: /{channel:(\i),name:\i,muted:(\i).+?;/, replace: (m, channel, muted) => `${m}${muted}=$self.isHiddenChannel(${channel})?true:${muted};` }, - // Add the hidden eye icon if the channel is hidden - { - match: /\.name\),.{0,120}\.children.+?:null(?<=,channel:(\i).+?)/, - replace: (m, channel) => `${m},$self.isHiddenChannel(${channel})?$self.HiddenChannelIcon():null` - }, // Make voice channels also appear as muted if they are muted { match: /(?<=\.wrapper:\i\.notInteractive,)(.+?)if\((\i)\)return (\i\.MUTED);/, replace: (_, otherClasses, isMuted, mutedClassExpression) => `${isMuted}?${mutedClassExpression}:"",${otherClasses}if(${isMuted})return "";` + }, + { + // Make muted channels also appear as unread if hide unreads is false and the channel is hidden + predicate: () => settings.store.channelStyle === ChannelStyle.MutedUnread || settings.store.channelStyle === ChannelStyle.Unread, + match: /\.LOCKED;if\((?<={channel:(\i).+?)/, + replace: (m, channel) => `${m}!$self.isHiddenChannel(${channel})&&` } ] }, { find: "UNREAD_IMPORTANT:", + predicate: () => settings.store.channelStyle !== ChannelStyle.Unread && settings.store.channelStyle !== ChannelStyle.MutedUnread, replacement: [ - { - // Make muted channels also appear as unread if hide unreads is false, using the HiddenIconWithMutedStyle and the channel is hidden - predicate: () => settings.store.hideUnreads === false && settings.store.showMode === ShowMode.HiddenIconWithMutedStyle, - match: /\.LOCKED;if\((?<={channel:(\i).+?)/, - replace: (m, channel) => `${m}!$self.isHiddenChannel(${channel})&&` - }, { // Hide unreads - predicate: () => settings.store.hideUnreads === true, match: /{channel:(\i),name:\i,.+?unread:(\i).+?;/, replace: (m, channel, unread) => `${m}${unread}=$self.isHiddenChannel(${channel})?false:${unread};` } @@ -543,7 +570,7 @@ export default definePlugin({ ), { noop: true }), - HiddenChannelIcon: ErrorBoundary.wrap(() => ( + EyeRightIcon: ErrorBoundary.wrap(() => ( {({ onMouseLeave, onMouseEnter }) => ( )} + ), { noop: true }), + + LockRightIcon: ErrorBoundary.wrap(() => ( + + {({ onMouseLeave, onMouseEnter }) => ( + + + + )} + ), { noop: true }) }); diff --git a/src/utils/constants.ts b/src/utils/constants.ts index 83a41713..e58401d0 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -943,7 +943,11 @@ export const EquicordDevs = Object.freeze({ Z1xus: { name: "Z1xus", id: 377450600797044746n, - } + }, + Oggetto: { + name: "Oggetto", + id: 619203349954166804n, + }, } satisfies Record); // iife so #__PURE__ works correctly