Fix calling clearTimeout instead of clearInterval in app script (no difference according to spec, but cleaner)

This commit is contained in:
chylex committed 2022-02-12 20:40:57 +01:00
1 parent 0662af9b1a
commit d772f7ed71
2 files changed
+4 -4

No files matched your search

+1 -2
View File
@@ -125,8 +125,7 @@
}
};
const callbackTimer = DISCORD.setupMessageCallback(onMessagesUpdated);
window.DHT_ON_UNLOAD.push(() => window.clearTimeout(callbackTimer));
DISCORD.setupMessageCallback(onMessagesUpdated);
STATE.onTrackingStateChanged(enabled => {
if (enabled) {
+3 -2
View File
@@ -26,14 +26,13 @@ class DISCORD {
/**
* Calls the provided function with a list of messages whenever the currently loaded messages change.
* Returns a setInterval handle.
*/
static setupMessageCallback(callback) {
let skipsLeft = 0;
let waitForCleanup = false;
const previousMessages = new Set();
return window.setInterval(() => {
const timer = window.setInterval(() => {
if (skipsLeft > 0) {
--skipsLeft;
return;
@@ -88,6 +87,8 @@ class DISCORD {
callback(messages);
}, 200);
window.DHT_ON_UNLOAD.push(() => window.clearInterval(timer));
}
/**