add debounce

This commit is contained in:
Amia 2024-05-24 17:25:25 +02:00
parent a24967ed2f
commit 5f5e9c9558
No known key found for this signature in database
GPG key ID: 9B2D60034D0730F2

View file

@ -161,10 +161,14 @@ export default definePlugin({
}
},
debounce: new Set<string>(),
async processEmbeds(message: Message) {
if (message.state !== "SENT") return;
if (message.hasFlag(EMBED_SUPPRESSED)) return;
if (this.debounce.has(message.id)) return;
this.debounce.add(message.id);
let updateMessage = false;
const svgUrls = new Set(message.content.match(URL_REGEX));
@ -195,5 +199,7 @@ export default definePlugin({
if (updateMessage) {
FluxDispatcher.dispatch({ type: "MESSAGE_UPDATE", message });
}
this.debounce.delete(message.id);
}
});