mirror of
https://github.com/chylex/Discord-History-Tracker.git
synced 2025-04-14 07:37:13 +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);
|
DISCORD.setupMessageCallback(onMessagesUpdated);
|
||||||
window.DHT_ON_UNLOAD.push(() => window.clearTimeout(callbackTimer));
|
|
||||||
|
|
||||||
STATE.onTrackingStateChanged(enabled => {
|
STATE.onTrackingStateChanged(enabled => {
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
|
@ -26,14 +26,13 @@ class DISCORD {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Calls the provided function with a list of messages whenever the currently loaded messages change.
|
* Calls the provided function with a list of messages whenever the currently loaded messages change.
|
||||||
* Returns a setInterval handle.
|
|
||||||
*/
|
*/
|
||||||
static setupMessageCallback(callback) {
|
static setupMessageCallback(callback) {
|
||||||
let skipsLeft = 0;
|
let skipsLeft = 0;
|
||||||
let waitForCleanup = false;
|
let waitForCleanup = false;
|
||||||
const previousMessages = new Set();
|
const previousMessages = new Set();
|
||||||
|
|
||||||
return window.setInterval(() => {
|
const timer = window.setInterval(() => {
|
||||||
if (skipsLeft > 0) {
|
if (skipsLeft > 0) {
|
||||||
--skipsLeft;
|
--skipsLeft;
|
||||||
return;
|
return;
|
||||||
@ -88,6 +87,8 @@ class DISCORD {
|
|||||||
|
|
||||||
callback(messages);
|
callback(messages);
|
||||||
}, 200);
|
}, 200);
|
||||||
|
|
||||||
|
window.DHT_ON_UNLOAD.push(() => window.clearInterval(timer));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user