From 621ef197da55bab7974d6c0a48abf9a91ba68e55 Mon Sep 17 00:00:00 2001 From: LenAnderson Date: Mon, 22 Jul 2024 18:28:30 -0400 Subject: [PATCH] don't update command progress CSS property if not changed performance improvement from luccy --- public/scripts/slash-commands.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/public/scripts/slash-commands.js b/public/scripts/slash-commands.js index 95c6a9fb6..ae94ff785 100644 --- a/public/scripts/slash-commands.js +++ b/public/scripts/slash-commands.js @@ -3498,11 +3498,18 @@ export async function executeSlashCommandsOnChatInput(text, options = {}) { /**@type {SlashCommandClosureResult} */ let result = null; + let currentProgress = ''; try { commandsFromChatInputAbortController = new SlashCommandAbortController(); result = await executeSlashCommandsWithOptions(text, { abortController: commandsFromChatInputAbortController, - onProgress: (done, total) => ta.style.setProperty('--prog', `${done / total * 100}%`), + onProgress: (done, total) => { + const newProgress = `${done / total * 100}%`; + if (newProgress !== currentProgress) { + currentProgress = newProgress; + ta.style.setProperty('--prog', newProgress); + } + }, parserFlags: options.parserFlags, scope: options.scope, source: options.source,