don't let progress bar go backwards

This commit is contained in:
LenAnderson 2024-07-26 22:20:21 -04:00
parent 646f77f9f8
commit b7e8f8faaa
1 changed files with 4 additions and 4 deletions

View File

@ -3499,16 +3499,16 @@ export async function executeSlashCommandsOnChatInput(text, options = {}) {
/**@type {SlashCommandClosureResult} */ /**@type {SlashCommandClosureResult} */
let result = null; let result = null;
let currentProgress = ''; let currentProgress = 0;
try { try {
commandsFromChatInputAbortController = new SlashCommandAbortController(); commandsFromChatInputAbortController = new SlashCommandAbortController();
result = await executeSlashCommandsWithOptions(text, { result = await executeSlashCommandsWithOptions(text, {
abortController: commandsFromChatInputAbortController, abortController: commandsFromChatInputAbortController,
onProgress: (done, total) => { onProgress: (done, total) => {
const newProgress = `${done / total * 100}%`; const newProgress = done / total;
if (newProgress !== currentProgress) { if (newProgress > currentProgress) {
currentProgress = newProgress; currentProgress = newProgress;
ta.style.setProperty('--prog', newProgress); ta.style.setProperty('--prog', `${newProgress * 100}%`);
} }
}, },
parserFlags: options.parserFlags, parserFlags: options.parserFlags,