[Splash] Rewrite state handling to use switch and have more parity with original
This commit is contained in:
parent
7598051419
commit
c381ac913f
1 changed files with 14 additions and 8 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue