Merge remote-tracking branch 'upstream/dev' into dev

This commit is contained in:
thororen1234 2024-11-05 17:36:54 -05:00
commit 5c719d8038
2 changed files with 39 additions and 11 deletions

View file

@ -16,7 +16,6 @@ import { disableStyle, enableStyle } from "@api/Styles";
import ErrorBoundary from "@components/ErrorBoundary"; import ErrorBoundary from "@components/ErrorBoundary";
import { Devs } from "@utils/constants"; import { Devs } from "@utils/constants";
import { getIntlMessage } from "@utils/discord"; import { getIntlMessage } from "@utils/discord";
import { proxyLazy } from "@utils/lazy";
import { Logger } from "@utils/Logger"; import { Logger } from "@utils/Logger";
import { classes } from "@utils/misc"; import { classes } from "@utils/misc";
import definePlugin, { OptionType } from "@utils/types"; import definePlugin, { OptionType } from "@utils/types";
@ -349,11 +348,35 @@ export default definePlugin({
); );
}, },
Messages: proxyLazy(() => ({ Messages: {
DELETED_MESSAGE_COUNT: getMessage( // DELETED_MESSAGE_COUNT: getMessage("{count, plural, =0 {No deleted messages} one {{count} deleted message} other {{count} deleted messages}}")
"{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: [ patches: [
{ {

View file

@ -18,18 +18,18 @@
import { Settings } from "@api/Settings"; import { Settings } from "@api/Settings";
import { Devs } from "@utils/constants"; import { Devs } from "@utils/constants";
import { runtimeHashMessageKey } from "@utils/intlHash";
import { Logger } from "@utils/Logger"; import { Logger } from "@utils/Logger";
import definePlugin, { OptionType } from "@utils/types"; import definePlugin, { OptionType } from "@utils/types";
import { findByPropsLazy } from "@webpack"; import { findByPropsLazy } from "@webpack";
import { MessageStore } from "@webpack/common"; import { i18n, MessageStore } from "@webpack/common";
import { Message } from "discord-types/general"; import { Message } from "discord-types/general";
const RelationshipStore = findByPropsLazy("getRelationships", "isBlocked"); const RelationshipStore = findByPropsLazy("getRelationships", "isBlocked");
interface MessageDeleteProps { interface MessageDeleteProps {
collapsedReason: { // i18n message i18n.t["+FcYMz"] if deleted, with args
message: string; collapsedReason: () => any
};
} }
export default definePlugin({ export default definePlugin({
@ -102,6 +102,11 @@ export default definePlugin({
}, },
shouldHide(props: MessageDeleteProps) { 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;
} }
}); });