diff --git a/package.json b/package.json index 3b0d499b..bffe6e72 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "equicord", "private": "true", - "version": "1.10.1", + "version": "1.10.2", "description": "The other cutest Discord client mod", "homepage": "https://github.com/Equicord/Equicord#readme", "bugs": { diff --git a/src/plugins/clearURLs/defaultRules.ts b/src/plugins/clearURLs/defaultRules.ts index e02b032f..7bbb3d68 100644 --- a/src/plugins/clearURLs/defaultRules.ts +++ b/src/plugins/clearURLs/defaultRules.ts @@ -158,4 +158,5 @@ export const defaultRules = [ "igshid", "igsh", "share_id@reddit.com", + "si@soundcloud.com", ]; diff --git a/src/plugins/showHiddenThings/index.ts b/src/plugins/showHiddenThings/index.ts index 9ffaa7e1..847dcd32 100644 --- a/src/plugins/showHiddenThings/index.ts +++ b/src/plugins/showHiddenThings/index.ts @@ -112,12 +112,12 @@ export default definePlugin({ }, // patch request that queries if term is allowed { - find: ".GUILD_DISCOVERY_VALID_TERM", + find: ".GUILD_DISCOVERY_VALID_TERM,query:", predicate: () => settings.store.disableDisallowedDiscoveryFilters, all: true, replacement: { - match: /\i\.\i\.get\(\{url:\i\.\i\.GUILD_DISCOVERY_VALID_TERM,query:\{term:\i\},oldFormErrors:!0\}\);/g, - replace: "Promise.resolve({ body: { valid: true } });" + match: /\i\.\i\.get\(\{url:\i\.\i\.GUILD_DISCOVERY_VALID_TERM,query:\{term:\i\},oldFormErrors:!0\}\)/g, + replace: "Promise.resolve({ body: { valid: true } })" } } ], diff --git a/src/plugins/userVoiceShow/components.tsx b/src/plugins/userVoiceShow/components.tsx index c04820e8..f248cf72 100644 --- a/src/plugins/userVoiceShow/components.tsx +++ b/src/plugins/userVoiceShow/components.tsx @@ -7,17 +7,24 @@ import { classNameFactory } from "@api/Styles"; import ErrorBoundary from "@components/ErrorBoundary"; import { classes } from "@utils/misc"; -import { findByPropsLazy, findComponentByCodeLazy, findStoreLazy } from "@webpack"; -import { ChannelStore, GuildStore, IconUtils, NavigationRouter, PermissionsBits, PermissionStore, showToast, Text, Toasts, Tooltip, useCallback, useMemo, UserStore, useStateFromStores } from "@webpack/common"; +import { filters, findByCodeLazy, findByPropsLazy, findComponentByCodeLazy, findStoreLazy, mapMangledModuleLazy } from "@webpack"; +import { ChannelStore, GuildStore, IconUtils, match, NavigationRouter, P, PermissionsBits, PermissionStore, React, showToast, Text, Toasts, Tooltip, useMemo, UserStore, useStateFromStores } from "@webpack/common"; import { Channel } from "discord-types/general"; const cl = classNameFactory("vc-uvs-"); -const { selectVoiceChannel } = findByPropsLazy("selectChannel", "selectVoiceChannel"); +const { selectVoiceChannel } = findByPropsLazy("selectVoiceChannel", "selectChannel"); +const { useChannelName } = mapMangledModuleLazy(".Messages.GROUP_DM_ALONE", { + useChannelName: filters.byCode("()=>null==") +}); +const getDMChannelIcon = findByCodeLazy(".getChannelIconURL({"); const VoiceStateStore = findStoreLazy("VoiceStateStore"); -const UserSummaryItem = findComponentByCodeLazy("defaultRenderUser", "showDefaultAvatarsForNullUsers"); -interface IconProps extends React.HTMLAttributes { +const UserSummaryItem = findComponentByCodeLazy("defaultRenderUser", "showDefaultAvatarsForNullUsers"); +const Avatar = findComponentByCodeLazy(".AVATAR_STATUS_TYPING_16;"); +const GroupDMAvatars = findComponentByCodeLazy(".AvatarSizeSpecs[", "getAvatarURL"); + +interface IconProps extends React.ComponentPropsWithoutRef<"div"> { size?: number; } @@ -28,7 +35,7 @@ function SpeakerIcon(props: IconProps) {
VoiceStateStore.getVoiceStatesForChannel(channel.id)); + const users = useMemo( () => Object.values(voiceStates).map(voiceState => UserStore.getUser(voiceState.userId)).filter(user => user != null), [voiceStates] ); - const guild = useMemo( - () => channel.getGuildId() == null ? undefined : GuildStore.getGuild(channel.getGuildId()), - [channel] - ); + const guild = channel.getGuildId() == null ? undefined : GuildStore.getGuild(channel.getGuildId()); + const guildIcon = guild?.icon == null ? undefined : IconUtils.getGuildIconURL({ + id: guild.id, + icon: guild.icon, + size: 30 + }); - const guildIcon = useMemo(() => { - return guild?.icon == null ? undefined : IconUtils.getGuildIconURL({ - id: guild.id, - icon: guild.icon, - size: 30 - }); - }, [guild]); + const channelIcon = match(channel.type) + .with(P.union(1, 3), () => { + return channel.recipients.length >= 2 && channel.icon == null + ? + : ; + }) + .otherwise(() => null); + const channelName = useChannelName(channel); return ( <> {guild != null && ( -
+
{guildIcon != null && } {guild.name}
)} - {channel.name} +
+ {channelIcon} + {channelName} +
@@ -113,20 +127,28 @@ function VoiceChannelTooltip({ channel }: VoiceChannelTooltipProps) { interface VoiceChannelIndicatorProps { userId: string; + isActionButton?: boolean; + isMessageIndicator?: boolean; } const clickTimers = {} as Record; -export const VoiceChannelIndicator = ErrorBoundary.wrap(({ userId }: VoiceChannelIndicatorProps) => { +export const VoiceChannelIndicator = ErrorBoundary.wrap(({ userId, isActionButton, isMessageIndicator }: VoiceChannelIndicatorProps) => { const channelId = useStateFromStores([VoiceStateStore], () => VoiceStateStore.getVoiceStateForUser(userId)?.channelId as string | undefined); - const channel = useMemo(() => channelId == null ? undefined : ChannelStore.getChannel(channelId), [channelId]); - const onClick = useCallback((e: React.MouseEvent) => { + const channel = channelId == null ? undefined : ChannelStore.getChannel(channelId); + if (channel == null) return null; + + const isDM = channel.isDM() || channel.isMultiUserDM(); + const isLocked = !isDM && (!PermissionStore.can(PermissionsBits.VIEW_CHANNEL, channel) || !PermissionStore.can(PermissionsBits.CONNECT, channel)); + + function onClick(e: React.MouseEvent) { e.preventDefault(); e.stopPropagation(); + if (channel == null || channelId == null) return; - if (!PermissionStore.can(PermissionsBits.VIEW_CHANNEL, channel)) { + if (!isDM && !PermissionStore.can(PermissionsBits.VIEW_CHANNEL, channel)) { showToast("You cannot view the user's Voice Channel", Toasts.Type.FAILURE); return; } @@ -135,7 +157,7 @@ export const VoiceChannelIndicator = ErrorBoundary.wrap(({ userId }: VoiceChanne delete clickTimers[channelId]; if (e.detail > 1) { - if (!PermissionStore.can(PermissionsBits.CONNECT, channel)) { + if (!isDM && !PermissionStore.can(PermissionsBits.CONNECT, channel)) { showToast("You cannot join the user's Voice Channel", Toasts.Type.FAILURE); return; } @@ -147,13 +169,7 @@ export const VoiceChannelIndicator = ErrorBoundary.wrap(({ userId }: VoiceChanne delete clickTimers[channelId]; }, 250); } - }, [channelId]); - - const isLocked = useMemo(() => { - return !PermissionStore.can(PermissionsBits.VIEW_CHANNEL, channel) || !PermissionStore.can(PermissionsBits.CONNECT, channel); - }, [channelId]); - - if (channel == null) return null; + } return ( - {props => - isLocked ? - - : - } + {props => { + const iconProps: IconProps = { + ...props, + className: isActionButton ? cl("indicator-action-button") : cl("speaker-padding"), + size: isActionButton ? 20 : undefined, + onClick + }; + + return
+ {isLocked ? + + : } +
; + }}
); }, { noop: true }); diff --git a/src/plugins/userVoiceShow/index.tsx b/src/plugins/userVoiceShow/index.tsx index 5efd936c..d30c5b7f 100644 --- a/src/plugins/userVoiceShow/index.tsx +++ b/src/plugins/userVoiceShow/index.tsx @@ -19,6 +19,7 @@ import "./style.css"; import { addDecorator, removeDecorator } from "@api/MemberListDecorators"; +import { addDecoration, removeDecoration } from "@api/MessageDecorations"; import { definePluginSettings } from "@api/Settings"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; @@ -37,13 +38,19 @@ const settings = definePluginSettings({ description: "Show a user's Voice Channel indicator in the member and DMs list", default: true, restartNeeded: true + }, + showInMessages: { + type: OptionType.BOOLEAN, + description: "Show a user's Voice Channel indicator in messages", + default: true, + restartNeeded: true } }); export default definePlugin({ name: "UserVoiceShow", description: "Shows an indicator when a user is in a Voice Channel", - authors: [Devs.LordElias, Devs.Nuckyz], + authors: [Devs.Nuckyz, Devs.LordElias], settings, patches: [ @@ -77,10 +84,10 @@ export default definePlugin({ }, */ // Friends List { - find: ".avatar,animate:", + find: "null!=this.peopleListItemRef.current", replacement: { - match: /\.subtext,children:.+?}\)\]}\)(?=])/, - replace: "$&,$self.VoiceChannelIndicator({userId:arguments[0]?.user?.id})" + match: /\.actions,children:\[/, + replace: "$&$self.VoiceChannelIndicator({userId:this?.props?.user?.id,isActionButton:true})," }, predicate: () => settings.store.showInMemberList } @@ -90,10 +97,14 @@ export default definePlugin({ if (settings.store.showInMemberList) { addDecorator("UserVoiceShow", ({ user }) => user == null ? null : ); } + if (settings.store.showInMessages) { + addDecoration("UserVoiceShow", ({ message }) => message?.author == null ? null : ); + } }, stop() { removeDecorator("UserVoiceShow"); + removeDecoration("UserVoiceShow"); }, VoiceChannelIndicator diff --git a/src/plugins/userVoiceShow/style.css b/src/plugins/userVoiceShow/style.css index 3e36df21..072dee94 100644 --- a/src/plugins/userVoiceShow/style.css +++ b/src/plugins/userVoiceShow/style.css @@ -1,6 +1,5 @@ .vc-uvs-speaker { color: var(--interactive-normal); - padding: 0 4px; display: flex; align-items: center; justify-content: center; @@ -14,6 +13,26 @@ color: var(--interactive-hover); } +.vc-uvs-speaker-padding { + padding: 0 4px; +} + +.vc-uvs-message-indicator { + display: inline-flex; + align-items: center; + justify-content: center; + top: 2.5px; + position: relative; +} + +.vc-uvs-indicator-action-button { + background-color: var(--background-secondary); + border-radius: 100%; + height: 36px; + width: 36px; + margin-left: 10px; +} + .vc-uvs-tooltip-container { max-width: 300px; } @@ -24,7 +43,7 @@ gap: 6px; } -.vc-uvs-guild-name { +.vc-uvs-name { display: flex; align-items: center; gap: 8px;