util: Fix call_function_periodically.

This function incorrectly and misleadingly did an immediate initial
call, despite both of its callers doing immediate calls themselves (in
one case, with a different parameter passed).

This led to unnecessary server load when reloading the app via event
system triggered reloads, since every client would call `/` twice.
This commit is contained in:
Tim Abbott 2024-02-02 12:58:38 -08:00
parent 652fea9bdf
commit 2c56978b02
1 changed files with 5 additions and 2 deletions

View File

@ -410,9 +410,12 @@ export function call_function_periodically(callback: () => void, delay: number):
// calling "callback".
setTimeout(() => {
call_function_periodically(callback, delay);
}, delay);
callback();
// Do the callback after scheduling the next call, so that we
// are certain to call it again even if the callback throws an
// exception.
callback();
}, delay);
}
export function get_string_diff(string1: string, string2: string): [number, number, number] {