[Splash > Backend] Rewrite fail scheduling

This commit is contained in:
Ducko 2022-04-20 12:17:12 +01:00
parent 18e13e0b1a
commit cc8be0a36d

View file

@ -164,9 +164,7 @@ const updateUntilCurrent = async () => {
} }
} catch (e) { } catch (e) {
log('Splash', e); log('Splash', e);
sendState('fail'); await new Promise(r => fail(r));
await new Promise(res => scheduleNextUpdate(res));
} }
} }
}; };
@ -179,8 +177,7 @@ const initModuleUpdater = () => { // "Old" (not v2 / new, win32 only)
const downloads = new UIProgress(0), installs = new UIProgress(1); const downloads = new UIProgress(0), installs = new UIProgress(1);
const handleFail = () => { const handleFail = () => {
scheduleNextUpdate(); fail(check);
sendState('fail');
}; };
on('update-check-finished', ({ succeeded, updateCount }) => { on('update-check-finished', ({ succeeded, updateCount }) => {
@ -235,10 +232,10 @@ const initModuleUpdater = () => { // "Old" (not v2 / new, win32 only)
check(); check();
}; };
const scheduleNextUpdate = (callback = moduleUpdater.checkForUpdates) => { // Used by v1 and v2, default to v1 as used more widely in it const fail = (c) => {
updateAttempt++; const s = 10;
splashState.seconds = s;
sendState('fail');
const wait = Math.min(updateAttempt * 10, 60); setTimeout(c, s * 1000);
splashState.seconds = wait;
setTimeout(callback, wait * 1000);
}; };