[Splash] Rewrite state handling to use switch and have more parity with original

This commit is contained in:
Ducko 2021-12-22 19:09:26 +00:00
parent 7598051419
commit c381ac913f

View file

@ -113,16 +113,22 @@
DiscordSplash.signalReady();
const outOfStates = [ 'downloading-updates', 'installing-updates' ];
const retryStates = [ 'update-failure' ];
DiscordSplash.onStateUpdate(({ status, current, total, progress, seconds }) => {
let text = status.replaceAll('-', ' ') + '...';
let text = status.replaceAll('-', ' ');
if (outOfStates.includes(status)) { // X out of Y states
text = text.slice(0, -4) + ` ${current} of ${total}`; // Remove "s..." and concat
}
if (retryStates.includes(status)) { // Retrying in X states
text = text.slice(0, -3) + ` - Retrying in ${seconds}`; // Remove "..." and concat
switch (status) {
case 'downloading-updates': // X of Y states
case 'installing-updates':
text = text.slice(0, -1) + ` ${current} of ${total}`; // Remove "s" and concat
break;
case 'update-failure': // Custom for update failure, include retry and reorder text
text = `Update Failed - Retrying in ${seconds}`;
break;
case 'launching':
text = 'Starting...';
break;
}
text.textContent = text;