mirror of
https://github.com/chylex/Discord-History-Tracker.git
synced 2025-04-13 07:17:12 +03:00
Fix calling clearTimeout instead of clearInterval in app script (no difference according to spec, but cleaner)
This commit is contained in:
parent
0662af9b1a
commit
d772f7ed71
3
app/Resources/Tracker/bootstrap.js
vendored
3
app/Resources/Tracker/bootstrap.js
vendored
@ -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) {
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user