From e45b867ff0309aca02e6165230d8706c00bb41d9 Mon Sep 17 00:00:00 2001 From: jamesbt365 Date: Fri, 24 Jan 2025 23:42:05 +0000 Subject: [PATCH 1/5] ServerInfo: Add Ignored Users tab (#3127) --- src/plugins/serverInfo/GuildInfoModal.tsx | 23 ++++++++++++++++++++--- src/webpack/common/stores.ts | 1 + 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/plugins/serverInfo/GuildInfoModal.tsx b/src/plugins/serverInfo/GuildInfoModal.tsx index be77ca1c..14b7e1dc 100644 --- a/src/plugins/serverInfo/GuildInfoModal.tsx +++ b/src/plugins/serverInfo/GuildInfoModal.tsx @@ -31,7 +31,8 @@ export function openGuildInfoModal(guild: Guild) { const enum Tabs { ServerInfo, Friends, - BlockedUsers + BlockedUsers, + IgnoredUsers } interface GuildProps { @@ -44,7 +45,8 @@ interface RelationshipProps extends GuildProps { const fetched = { friends: false, - blocked: false + blocked: false, + ignored: false }; function renderTimestamp(timestamp: number) { @@ -56,10 +58,12 @@ function renderTimestamp(timestamp: number) { function GuildInfoModal({ guild }: GuildProps) { const [friendCount, setFriendCount] = useState(); const [blockedCount, setBlockedCount] = useState(); + const [ignoredCount, setIgnoredCount] = useState(); useEffect(() => { fetched.friends = false; fetched.blocked = false; + fetched.ignored = false; }, []); const [currentTab, setCurrentTab] = useState(Tabs.ServerInfo); @@ -132,12 +136,19 @@ function GuildInfoModal({ guild }: GuildProps) { > Blocked Users{blockedCount !== undefined ? ` (${blockedCount})` : ""} + + Ignored Users{ignoredCount !== undefined ? ` (${ignoredCount})` : ""} +
{currentTab === Tabs.ServerInfo && } {currentTab === Tabs.Friends && } {currentTab === Tabs.BlockedUsers && } + {currentTab === Tabs.IgnoredUsers && }
); @@ -211,7 +222,13 @@ function BlockedUsersTab({ guild, setCount }: RelationshipProps) { return UserList("blocked", guild, blockedIds, setCount); } -function UserList(type: "friends" | "blocked", guild: Guild, ids: string[], setCount: (count: number) => void) { +function IgnoredUserTab({ guild, setCount }: RelationshipProps) { + const ignoredIds = Object.keys(RelationshipStore.getRelationships()).filter(id => RelationshipStore.isIgnored(id)); + return UserList("ignored", guild, ignoredIds, setCount); +} + + +function UserList(type: "friends" | "blocked" | "ignored", guild: Guild, ids: string[], setCount: (count: number) => void) { const missing = [] as string[]; const members = [] as string[]; diff --git a/src/webpack/common/stores.ts b/src/webpack/common/stores.ts index 8579f8b9..ff668425 100644 --- a/src/webpack/common/stores.ts +++ b/src/webpack/common/stores.ts @@ -50,6 +50,7 @@ export let GuildMemberStore: Stores.GuildMemberStore & t.FluxStore; export let RelationshipStore: Stores.RelationshipStore & t.FluxStore & { /** Get the date (as a string) that the relationship was created */ getSince(userId: string): string; + isIgnored(userId: string): boolean; }; export let EmojiStore: t.EmojiStore; From 7ee70e831a00b6ca48f73667e6e8f220415abf9e Mon Sep 17 00:00:00 2001 From: jamesbt365 Date: Fri, 24 Jan 2025 23:46:47 +0000 Subject: [PATCH 2/5] MessageLogger: Make collapseDeleted require a restart (#2923) --- src/plugins/messageLogger/index.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/messageLogger/index.tsx b/src/plugins/messageLogger/index.tsx index 333de9a4..9b6b864a 100644 --- a/src/plugins/messageLogger/index.tsx +++ b/src/plugins/messageLogger/index.tsx @@ -211,7 +211,8 @@ export default definePlugin({ collapseDeleted: { type: OptionType.BOOLEAN, description: "Whether to collapse deleted messages, similar to blocked messages", - default: false + default: false, + restartNeeded: true, }, logEdits: { type: OptionType.BOOLEAN, From 79cbfe96c8a444a51644d366ec6ecae00ad6a735 Mon Sep 17 00:00:00 2001 From: jamesbt365 Date: Fri, 24 Jan 2025 23:56:39 +0000 Subject: [PATCH 3/5] HideAttachments, UnsupressEmbeds: Work with forwarded messages (#2928) --- src/plugins/hideAttachments/index.tsx | 8 +++++++- src/plugins/unsuppressEmbeds/index.tsx | 10 ++++++++-- src/webpack/common/types/utils.d.ts | 6 +++++- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/plugins/hideAttachments/index.tsx b/src/plugins/hideAttachments/index.tsx index e122e3cb..39935d03 100644 --- a/src/plugins/hideAttachments/index.tsx +++ b/src/plugins/hideAttachments/index.tsx @@ -21,6 +21,7 @@ import { ImageInvisible, ImageVisible } from "@components/Icons"; import { Devs } from "@utils/constants"; import definePlugin from "@utils/types"; import { ChannelStore } from "@webpack/common"; +import { MessageSnapshot } from "@webpack/types"; let style: HTMLStyleElement; @@ -39,7 +40,12 @@ export default definePlugin({ authors: [Devs.Ven], renderMessagePopoverButton(msg) { - if (!msg.attachments.length && !msg.embeds.length && !msg.stickerItems.length) return null; + // @ts-ignore - discord-types lags behind discord. + const hasAttachmentsInShapshots = msg.messageSnapshots.some( + (snapshot: MessageSnapshot) => snapshot?.message.attachments.length + ); + + if (!msg.attachments.length && !msg.embeds.length && !msg.stickerItems.length && !hasAttachmentsInShapshots) return null; const isHidden = hiddenMessages.has(msg.id); diff --git a/src/plugins/unsuppressEmbeds/index.tsx b/src/plugins/unsuppressEmbeds/index.tsx index 16debf71..2df64b72 100644 --- a/src/plugins/unsuppressEmbeds/index.tsx +++ b/src/plugins/unsuppressEmbeds/index.tsx @@ -21,12 +21,18 @@ import { ImageInvisible, ImageVisible } from "@components/Icons"; import { Devs } from "@utils/constants"; import definePlugin from "@utils/types"; import { Constants, Menu, PermissionsBits, PermissionStore, RestAPI, UserStore } from "@webpack/common"; +import { MessageSnapshot } from "@webpack/types"; + const EMBED_SUPPRESSED = 1 << 2; -const messageContextMenuPatch: NavContextMenuPatchCallback = (children, { channel, message: { author, embeds, flags, id: messageId } }) => { +const messageContextMenuPatch: NavContextMenuPatchCallback = (children, { channel, message: { author, messageSnapshots, embeds, flags, id: messageId } }) => { const isEmbedSuppressed = (flags & EMBED_SUPPRESSED) !== 0; - if (!isEmbedSuppressed && !embeds.length) return; + const hasEmbedsInSnapshots = messageSnapshots.some( + (snapshot: MessageSnapshot) => snapshot?.message.embeds.length + ); + + if (!isEmbedSuppressed && !embeds.length && !hasEmbedsInSnapshots) return; const hasEmbedPerms = channel.isPrivate() || !!(PermissionStore.getChannelPermissions({ id: channel.id }) & PermissionsBits.EMBED_LINKS); if (author.id === UserStore.getCurrentUser().id && !hasEmbedPerms) return; diff --git a/src/webpack/common/types/utils.d.ts b/src/webpack/common/types/utils.d.ts index de1ce182..cfea5d76 100644 --- a/src/webpack/common/types/utils.d.ts +++ b/src/webpack/common/types/utils.d.ts @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import { Channel, Guild, GuildMember, User } from "discord-types/general"; +import { Channel, Guild, GuildMember, Message, User } from "discord-types/general"; import type { ReactNode } from "react"; import { LiteralUnion } from "type-fest"; @@ -133,6 +133,10 @@ export type Permissions = "CREATE_INSTANT_INVITE" export type PermissionsBits = Record; +export interface MessageSnapshot { + message: Message; +} + export interface Locale { name: string; value: string; From 4036fbab92d5534417dedd6a5e8e7ecdc4e41dc6 Mon Sep 17 00:00:00 2001 From: sadan4 <117494111+sadan4@users.noreply.github.com> Date: Fri, 24 Jan 2025 19:01:12 -0500 Subject: [PATCH 4/5] ConsoleJanitor: Remove old patch and add getLastCrash (#3151) --- src/plugins/consoleJanitor/index.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/plugins/consoleJanitor/index.ts b/src/plugins/consoleJanitor/index.ts index d251ff74..aa28e885 100644 --- a/src/plugins/consoleJanitor/index.ts +++ b/src/plugins/consoleJanitor/index.ts @@ -95,10 +95,9 @@ export default definePlugin({ } }, { - find: 'console.warn("[DEPRECATED] Please use `subscribeWithSelector` middleware");', - all: true, + find: '"AppCrashedFatalReport: getLastCrash not supported."', replacement: { - match: /console\.warn\("\[DEPRECATED\] Please use `subscribeWithSelector` middleware"\);/, + match: /console\.log\("AppCrashedFatalReport: getLastCrash not supported\."\);/, replace: "" } }, From aac5242dc8e4cbac6a7fc99a084707b973eabfbc Mon Sep 17 00:00:00 2001 From: sadan4 <117494111+sadan4@users.noreply.github.com> Date: Fri, 24 Jan 2025 19:11:26 -0500 Subject: [PATCH 5/5] ImageZoom: Fix incorrectly adding context menu in some places (#3150) --- src/plugins/imageZoom/index.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/plugins/imageZoom/index.tsx b/src/plugins/imageZoom/index.tsx index 06e1dcd5..8c50ae9f 100644 --- a/src/plugins/imageZoom/index.tsx +++ b/src/plugins/imageZoom/index.tsx @@ -81,7 +81,12 @@ export const settings = definePluginSettings({ }); -const imageContextMenuPatch: NavContextMenuPatchCallback = children => { +const imageContextMenuPatch: NavContextMenuPatchCallback = (children, props) => { + // Discord re-uses the image context menu for links to for the copy and open buttons + if ("href" in props) return; + // emojis in user statuses + if (props.target?.classList?.contains("emoji")) return; + const { square, nearestNeighbour } = settings.use(["square", "nearestNeighbour"]); children.push(