From 8e952c630bf65f86b85dd3a524e6f31dc4d0599e Mon Sep 17 00:00:00 2001 From: AutumnVN Date: Wed, 6 Sep 2023 00:39:22 +0700 Subject: MessageLogger: fix ignore by id doesn't ignore edited (#1705) --- src/plugins/messageLogger/index.tsx | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'src/plugins/messageLogger/index.tsx') diff --git a/src/plugins/messageLogger/index.tsx b/src/plugins/messageLogger/index.tsx index 0e6f118..0be616a 100644 --- a/src/plugins/messageLogger/index.tsx +++ b/src/plugins/messageLogger/index.tsx @@ -169,21 +169,14 @@ export default definePlugin({ try { if (cache == null || (!isBulk && !cache.has(data.id))) return cache; - const { ignoreBots, ignoreSelf, ignoreUsers, ignoreChannels, ignoreGuilds } = Settings.plugins.MessageLogger; - const myId = UserStore.getCurrentUser().id; - - function mutate(id: string) { + const mutate = (id: string) => { const msg = cache.get(id); if (!msg) return; const EPHEMERAL = 64; const shouldIgnore = data.mlDeleted || (msg.flags & EPHEMERAL) === EPHEMERAL || - ignoreBots && msg.author?.bot || - ignoreSelf && msg.author?.id === myId || - ignoreUsers.includes(msg.author?.id) || - ignoreChannels.includes(msg.channel_id) || - ignoreGuilds.includes(ChannelStore.getChannel(msg.channel_id)?.guild_id); + this.shouldIgnore(msg); if (shouldIgnore) { cache = cache.remove(id); @@ -192,7 +185,7 @@ export default definePlugin({ .set("deleted", true) .set("attachments", m.attachments.map(a => (a.deleted = true, a)))); } - } + }; if (isBulk) { data.ids.forEach(mutate); @@ -205,6 +198,17 @@ export default definePlugin({ return cache; }, + shouldIgnore(message: any) { + const { ignoreBots, ignoreSelf, ignoreUsers, ignoreChannels, ignoreGuilds } = Settings.plugins.MessageLogger; + const myId = UserStore.getCurrentUser().id; + + return ignoreBots && message.author?.bot || + ignoreSelf && message.author?.id === myId || + ignoreUsers.includes(message.author?.id) || + ignoreChannels.includes(message.channel_id) || + ignoreGuilds.includes(ChannelStore.getChannel(message.channel_id)?.guild_id); + }, + // Based on canary 9ab8626bcebceaea6da570b9c586172d02b9c996 patches: [ { @@ -237,7 +241,7 @@ export default definePlugin({ match: /(MESSAGE_UPDATE:function\((\w)\).+?)\.update\((\w)/, replace: "$1" + ".update($3,m =>" + - " (($2.message.flags & 64) === 64 || (Vencord.Settings.plugins.MessageLogger.ignoreBots && $2.message.author?.bot) || (Vencord.Settings.plugins.MessageLogger.ignoreSelf && $2.message.author?.id === Vencord.Webpack.Common.UserStore.getCurrentUser().id)) ? m :" + + " (($2.message.flags & 64) === 64 || $self.shouldIgnore($2.message)) ? m :" + " $2.message.content !== m.editHistory?.[0]?.content && $2.message.content !== m.content ?" + " m.set('editHistory',[...(m.editHistory || []), $self.makeEdit($2.message, m)]) :" + " m" + -- cgit