From 9d4e859a0a2873d8afb7a6503261336628abbe77 Mon Sep 17 00:00:00 2001 From: sadan4 <117494111+sadan4@users.noreply.github.com> Date: Tue, 5 Nov 2024 17:01:52 -0500 Subject: [PATCH] NoBlockedMessages: Fix for new i18n lib (#2996) --- src/plugins/messageLogger/index.tsx | 33 ++++++++++++++++++++++---- src/plugins/noBlockedMessages/index.ts | 14 +++++++---- 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/src/plugins/messageLogger/index.tsx b/src/plugins/messageLogger/index.tsx index 3ee9f3fa..bc3c1ed9 100644 --- a/src/plugins/messageLogger/index.tsx +++ b/src/plugins/messageLogger/index.tsx @@ -25,7 +25,6 @@ import { disableStyle, enableStyle } from "@api/Styles"; import ErrorBoundary from "@components/ErrorBoundary"; import { Devs } from "@utils/constants"; import { getIntlMessage } from "@utils/discord"; -import { proxyLazy } from "@utils/lazy"; import { Logger } from "@utils/Logger"; import { classes } from "@utils/misc"; import definePlugin, { OptionType } from "@utils/types"; @@ -313,9 +312,35 @@ export default definePlugin({ ); }, - Messages: proxyLazy(() => ({ - DELETED_MESSAGE_COUNT: getMessage("{count, plural, =0 {No deleted messages} one {{count} deleted message} other {{count} deleted messages}}") - })), + Messages: { + // DELETED_MESSAGE_COUNT: getMessage("{count, plural, =0 {No deleted messages} one {{count} deleted message} other {{count} deleted messages}}") + // TODO: find a better way to generate intl messages + DELETED_MESSAGE_COUNT: () => ({ + ast: [[ + 6, + "count", + { + "=0": ["No deleted messages"], + one: [ + [ + 1, + "count" + ], + " deleted message" + ], + other: [ + [ + 1, + "count" + ], + " deleted messages" + ] + }, + 0, + "cardinal" + ]] + }) + }, patches: [ { diff --git a/src/plugins/noBlockedMessages/index.ts b/src/plugins/noBlockedMessages/index.ts index 7884aa29..1a1700e4 100644 --- a/src/plugins/noBlockedMessages/index.ts +++ b/src/plugins/noBlockedMessages/index.ts @@ -18,17 +18,18 @@ import { Settings } from "@api/Settings"; import { Devs } from "@utils/constants"; +import { runtimeHashMessageKey } from "@utils/intlHash"; import { Logger } from "@utils/Logger"; import definePlugin, { OptionType } from "@utils/types"; import { findByPropsLazy } from "@webpack"; +import { i18n } from "@webpack/common"; import { Message } from "discord-types/general"; const RelationshipStore = findByPropsLazy("getRelationships", "isBlocked"); interface MessageDeleteProps { - collapsedReason: { - message: string; - }; + // i18n message i18n.t["+FcYMz"] if deleted, with args + collapsedReason: () => any } export default definePlugin({ @@ -77,6 +78,11 @@ export default definePlugin({ }, shouldHide(props: MessageDeleteProps) { - return !props?.collapsedReason?.message.includes("deleted"); + try { + return props.collapsedReason() === i18n.t[runtimeHashMessageKey("BLOCKED_MESSAGE_COUNT")](); + } catch (e) { + console.error(e); + } + return false; } });