Async logic fixes
| @@ -4,7 +4,7 @@ import { eventSource, event_types, saveSettings, saveSettingsDebounced, getReque | ||
| 4 | 4 | import { showLoader } from './loader.js'; |
| 5 | 5 | import { POPUP_RESULT, POPUP_TYPE, Popup, callGenericPopup } from './popup.js'; |
| 6 | 6 | import { renderTemplate, renderTemplateAsync } from './templates.js'; |
| 7 | 7 | import { delay, isSubsetOf, setValueByPath } from './utils.js'; |
| 8 | 8 | import { getContext } from './st-context.js'; |
| 9 | 9 | import { isAdmin } from './user.js'; |
| 10 | 10 | import { t } from './i18n.js'; |
| @@ -689,6 +689,8 @@ async function showExtensionsDetails() { | ||
| 689 | 689 | const abortController = new AbortController(); |
| 690 | 690 | let popupPromise; |
| 691 | 691 | try { |
| 692 | + // If we are updating an extension, the "old" popup is still active. We should close that. | |
| 693 | + await Popup.util.popups.find(popup => popup.content.querySelector('.extensions_info'))?.completeCancelled(); | |
| 692 | 694 | const htmlDefault = $('<div class="marginBot10"><h3 class="textAlignCenter">Built-in Extensions:</h3></div>'); |
| 693 | 695 | const htmlExternal = $('<div class="marginBot10"><h3 class="textAlignCenter">Installed Extensions:</h3></div>'); |
| 694 | 696 | const htmlLoading = $(`<div class="flex-container alignItemsCenter justifyCenter marginTop10 marginBot5"> |
| @@ -723,12 +725,6 @@ async function showExtensionsDetails() { | ||
| 723 | 725 | }, |
| 724 | 726 | }; |
| 725 | 727 | |
| 726 | - // If we are updating an extension, the "old" popup is still active. We should close that. | |
| 727 | - const oldPopup = Popup.util.popups.find(popup => popup.content.querySelector('.extensions_info')); | |
| 728 | - if (oldPopup) { | |
| 729 | - await oldPopup.complete(POPUP_RESULT.CANCELLED); | |
| 730 | - } | |
| 731 | - | |
| 732 | 728 | let waitingForSave = false; |
| 733 | 729 | |
| 734 | 730 | const popup = new Popup(html, POPUP_TYPE.TEXT, '', { |
| @@ -816,7 +812,7 @@ async function updateExtension(extensionName, quiet) { | ||
| 816 | 812 | const data = await response.json(); |
| 817 | 813 | |
| 818 | 814 | if (!quiet) { |
| 819 | 815 | awaitvoid showExtensionsDetails(); |
| 820 | 816 | } |
| 821 | 817 | |
| 822 | 818 | if (data.isUpToDate) { |
| @@ -908,8 +904,7 @@ async function moveExtension(extensionName, source, destination) { | ||
| 908 | 904 | |
| 909 | 905 | toastr.success(t`Extension ${extensionName} moved.`); |
| 910 | 906 | await loadExtensionSettings({}, false, false); |
| 911 | - await Popup.util.popups.find(popup => popup.content.querySelector('.extensions_info'))?.completeCancelled(); | |
| 907 | + void showExtensionsDetails(); | |
| 912 | - showExtensionsDetails(); | |
| 913 | 908 | } catch (error) { |
| 914 | 909 | console.error('Error:', error); |
| 915 | 910 | } |
| @@ -934,9 +929,7 @@ export async function deleteExtension(extensionName) { | ||
| 934 | 929 | } |
| 935 | 930 | |
| 936 | 931 | toastr.success(t`Extension ${extensionName} deleted`); |
| 937 | - showExtensionsDetails(); | |
| 932 | + delay(1000).then(() => location.reload()); | |
| 938 | - // reload the page to remove the extension from the list | |
| 939 | - location.reload(); | |
| 940 | 933 | } |
| 941 | 934 | |
| 942 | 935 | /** |