[Splash] Rewrite state handling to add retry state and make messages same format as Discord's

This commit is contained in:
Ducko 2021-12-22 14:14:34 +00:00
parent 4e4ab5cd47
commit e371d6b106

View file

@ -114,9 +114,19 @@
DiscordSplash.signalReady();
const outOfStates = [ 'downloading-updates', 'installing-updates' ];
DiscordSplash.onStateUpdate(({ status, current, total, progress }) => {
text.textContent = status.replaceAll('-', ' ') + '...';
if (outOfStates.includes(state)) text.textContent += ` (${current}/${total})`;
const retryStates = [ 'update-failure' ];
DiscordSplash.onStateUpdate(({ status, current, total, progress, seconds }) => {
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
}
text.textContent = text;
if (progress) {
barContainer.style.visibility = 'visible';