From 41c709e291212291d3d1f61b5a25545258d0f5fb Mon Sep 17 00:00:00 2001 From: Wolfsblvt Date: Mon, 22 Jul 2024 02:11:11 +0200 Subject: [PATCH] WI slash only reload world if it was selected --- public/scripts/world-info.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/public/scripts/world-info.js b/public/scripts/world-info.js index 99ac56f2b..83377d7ba 100644 --- a/public/scripts/world-info.js +++ b/public/scripts/world-info.js @@ -885,9 +885,15 @@ function setWorldInfoSettings(settings, data) { } function registerWorldInfoSlashCommands() { - function reloadEditor(file) { + /** + * Reloads the editor with the specified world info file + * @param {string} file - The file to load in the editor + * @param {boolean} [loadIfNotSelected=false] - Indicates whether to load the file even if it's not currently selected + */ + function reloadEditor(file, loadIfNotSelected = false) { + const currentIndex = $('#world_editor_select').val(); const selectedIndex = world_names.indexOf(file); - if (selectedIndex !== -1) { + if (selectedIndex !== -1 && (loadIfNotSelected || currentIndex === selectedIndex)) { $('#world_editor_select').val(selectedIndex).trigger('change'); } }