[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();
|
DiscordSplash.signalReady();
|
||||||
|
|
||||||
const outOfStates = [ 'downloading-updates', 'installing-updates' ];
|
|
||||||
const retryStates = [ 'update-failure' ];
|
|
||||||
DiscordSplash.onStateUpdate(({ status, current, total, progress, seconds }) => {
|
DiscordSplash.onStateUpdate(({ status, current, total, progress, seconds }) => {
|
||||||
let text = status.replaceAll('-', ' ') + '...';
|
let text = status.replaceAll('-', ' ');
|
||||||
|
|
||||||
if (outOfStates.includes(status)) { // X out of Y states
|
switch (status) {
|
||||||
text = text.slice(0, -4) + ` ${current} of ${total}`; // Remove "s..." and concat
|
case 'downloading-updates': // X of Y states
|
||||||
}
|
case 'installing-updates':
|
||||||
if (retryStates.includes(status)) { // Retrying in X states
|
text = text.slice(0, -1) + ` ${current} of ${total}`; // Remove "s" and concat
|
||||||
text = text.slice(0, -3) + ` - Retrying in ${seconds}`; // Remove "..." 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;
|
text.textContent = text;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue