mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Async logic fixes
This commit is contained in:
@ -4,7 +4,7 @@ import { eventSource, event_types, saveSettings, saveSettingsDebounced, getReque
|
|||||||
import { showLoader } from './loader.js';
|
import { showLoader } from './loader.js';
|
||||||
import { POPUP_RESULT, POPUP_TYPE, Popup, callGenericPopup } from './popup.js';
|
import { POPUP_RESULT, POPUP_TYPE, Popup, callGenericPopup } from './popup.js';
|
||||||
import { renderTemplate, renderTemplateAsync } from './templates.js';
|
import { renderTemplate, renderTemplateAsync } from './templates.js';
|
||||||
import { isSubsetOf, setValueByPath } from './utils.js';
|
import { delay, isSubsetOf, setValueByPath } from './utils.js';
|
||||||
import { getContext } from './st-context.js';
|
import { getContext } from './st-context.js';
|
||||||
import { isAdmin } from './user.js';
|
import { isAdmin } from './user.js';
|
||||||
import { t } from './i18n.js';
|
import { t } from './i18n.js';
|
||||||
@ -689,6 +689,8 @@ async function showExtensionsDetails() {
|
|||||||
const abortController = new AbortController();
|
const abortController = new AbortController();
|
||||||
let popupPromise;
|
let popupPromise;
|
||||||
try {
|
try {
|
||||||
|
// If we are updating an extension, the "old" popup is still active. We should close that.
|
||||||
|
await Popup.util.popups.find(popup => popup.content.querySelector('.extensions_info'))?.completeCancelled();
|
||||||
const htmlDefault = $('<div class="marginBot10"><h3 class="textAlignCenter">Built-in Extensions:</h3></div>');
|
const htmlDefault = $('<div class="marginBot10"><h3 class="textAlignCenter">Built-in Extensions:</h3></div>');
|
||||||
const htmlExternal = $('<div class="marginBot10"><h3 class="textAlignCenter">Installed Extensions:</h3></div>');
|
const htmlExternal = $('<div class="marginBot10"><h3 class="textAlignCenter">Installed Extensions:</h3></div>');
|
||||||
const htmlLoading = $(`<div class="flex-container alignItemsCenter justifyCenter marginTop10 marginBot5">
|
const htmlLoading = $(`<div class="flex-container alignItemsCenter justifyCenter marginTop10 marginBot5">
|
||||||
@ -723,12 +725,6 @@ async function showExtensionsDetails() {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
// If we are updating an extension, the "old" popup is still active. We should close that.
|
|
||||||
const oldPopup = Popup.util.popups.find(popup => popup.content.querySelector('.extensions_info'));
|
|
||||||
if (oldPopup) {
|
|
||||||
await oldPopup.complete(POPUP_RESULT.CANCELLED);
|
|
||||||
}
|
|
||||||
|
|
||||||
let waitingForSave = false;
|
let waitingForSave = false;
|
||||||
|
|
||||||
const popup = new Popup(html, POPUP_TYPE.TEXT, '', {
|
const popup = new Popup(html, POPUP_TYPE.TEXT, '', {
|
||||||
@ -816,7 +812,7 @@ async function updateExtension(extensionName, quiet) {
|
|||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
|
|
||||||
if (!quiet) {
|
if (!quiet) {
|
||||||
await showExtensionsDetails();
|
void showExtensionsDetails();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.isUpToDate) {
|
if (data.isUpToDate) {
|
||||||
@ -908,8 +904,7 @@ async function moveExtension(extensionName, source, destination) {
|
|||||||
|
|
||||||
toastr.success(t`Extension ${extensionName} moved.`);
|
toastr.success(t`Extension ${extensionName} moved.`);
|
||||||
await loadExtensionSettings({}, false, false);
|
await loadExtensionSettings({}, false, false);
|
||||||
await Popup.util.popups.find(popup => popup.content.querySelector('.extensions_info'))?.completeCancelled();
|
void showExtensionsDetails();
|
||||||
showExtensionsDetails();
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error:', error);
|
console.error('Error:', error);
|
||||||
}
|
}
|
||||||
@ -934,9 +929,7 @@ export async function deleteExtension(extensionName) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
toastr.success(t`Extension ${extensionName} deleted`);
|
toastr.success(t`Extension ${extensionName} deleted`);
|
||||||
showExtensionsDetails();
|
delay(1000).then(() => location.reload());
|
||||||
// reload the page to remove the extension from the list
|
|
||||||
location.reload();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user