mirror of
https://github.com/Equicord/Equicord.git
synced 2025-01-18 05:13:29 -05:00
feat(shc): Add feature parity, more styles & show modes
Co-authored-by: JustOptimize <me@oggetto.zip>
This commit is contained in:
parent
193c65b182
commit
847a32765f
2 changed files with 74 additions and 24 deletions
|
@ -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({
|
|||
</svg>
|
||||
), { noop: true }),
|
||||
|
||||
HiddenChannelIcon: ErrorBoundary.wrap(() => (
|
||||
EyeRightIcon: ErrorBoundary.wrap(() => (
|
||||
<Tooltip text="Hidden Channel">
|
||||
{({ onMouseLeave, onMouseEnter }) => (
|
||||
<svg
|
||||
|
@ -560,5 +587,24 @@ export default definePlugin({
|
|||
</svg>
|
||||
)}
|
||||
</Tooltip>
|
||||
), { noop: true }),
|
||||
|
||||
LockRightIcon: ErrorBoundary.wrap(() => (
|
||||
<Tooltip text="Hidden Channel">
|
||||
{({ onMouseLeave, onMouseEnter }) => (
|
||||
<svg
|
||||
onMouseLeave={onMouseLeave}
|
||||
onMouseEnter={onMouseEnter}
|
||||
className={ChannelListClasses.icon + " " + "shc-hidden-channel-icon"}
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
aria-hidden={true}
|
||||
role="img"
|
||||
>
|
||||
<path className="shc-evenodd-fill-current-color" d="M17 11V7C17 4.243 14.756 2 12 2C9.242 2 7 4.243 7 7V11C5.897 11 5 11.896 5 13V20C5 21.103 5.897 22 7 22H17C18.103 22 19 21.103 19 20V13C19 11.896 18.103 11 17 11ZM12 18C11.172 18 10.5 17.328 10.5 16.5C10.5 15.672 11.172 15 12 15C12.828 15 13.5 15.672 13.5 16.5C13.5 17.328 12.828 18 12 18ZM15 11H9V7C9 5.346 10.346 4 12 4C13.654 4 15 5.346 15 7V11Z" />
|
||||
</svg>
|
||||
)}
|
||||
</Tooltip>
|
||||
), { noop: true })
|
||||
});
|
||||
|
|
|
@ -943,7 +943,11 @@ export const EquicordDevs = Object.freeze({
|
|||
Z1xus: {
|
||||
name: "Z1xus",
|
||||
id: 377450600797044746n,
|
||||
}
|
||||
},
|
||||
Oggetto: {
|
||||
name: "Oggetto",
|
||||
id: 619203349954166804n,
|
||||
},
|
||||
} satisfies Record<string, Dev>);
|
||||
|
||||
// iife so #__PURE__ works correctly
|
||||
|
|
Loading…
Reference in a new issue