diff options
author | AutumnVN <autumnvnchino@gmail.com> | 2023-09-06 00:39:22 +0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-05 19:39:22 +0200 |
commit | 8e952c630bf65f86b85dd3a524e6f31dc4d0599e (patch) | |
tree | a14f992d6617d6d7c7a41aeff821a82e33872c61 /src/plugins/messageLogger/index.tsx | |
parent | 2c758ccdf8372c48f2d2a79ece8f2eba63f1510c (diff) | |
download | Vencord-8e952c630bf65f86b85dd3a524e6f31dc4d0599e.tar.gz Vencord-8e952c630bf65f86b85dd3a524e6f31dc4d0599e.tar.bz2 Vencord-8e952c630bf65f86b85dd3a524e6f31dc4d0599e.zip |
MessageLogger: fix ignore by id doesn't ignore edited (#1705)
Diffstat (limited to 'src/plugins/messageLogger/index.tsx')
-rw-r--r-- | src/plugins/messageLogger/index.tsx | 26 |
1 files changed, 15 insertions, 11 deletions
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" + |