mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-02-12 10:00:36 +01:00
Fix 'preloader' overlay being removed too early
This commit is contained in:
parent
7344b63109
commit
47f00d3755
@ -43,7 +43,6 @@ import {
|
||||
saveGroupChat,
|
||||
getGroups,
|
||||
generateGroupWrapper,
|
||||
deleteGroup,
|
||||
is_group_generating,
|
||||
resetSelectedGroup,
|
||||
select_group_chats,
|
||||
@ -228,7 +227,7 @@ import { appendFileContent, hasPendingFileAttachment, populateFileAttachment, de
|
||||
import { initPresetManager } from './scripts/preset-manager.js';
|
||||
import { MacrosParser, evaluateMacros } from './scripts/macros.js';
|
||||
import { currentUser, setUserControls } from './scripts/user.js';
|
||||
import { POPUP_RESULT, POPUP_TYPE, Popup, callGenericPopup, fixToastrForDialogs } from './scripts/popup.js';
|
||||
import { POPUP_TYPE, Popup, callGenericPopup, fixToastrForDialogs } from './scripts/popup.js';
|
||||
import { renderTemplate, renderTemplateAsync } from './scripts/templates.js';
|
||||
import { ScraperManager } from './scripts/scrapers.js';
|
||||
import { SlashCommandParser } from './scripts/slash-commands/SlashCommandParser.js';
|
||||
@ -266,8 +265,6 @@ await new Promise((resolve) => {
|
||||
});
|
||||
|
||||
showLoader();
|
||||
// Yoink preloader entirely; it only exists to cover up unstyled content while loading JS
|
||||
document.getElementById('preloader').remove();
|
||||
|
||||
// Configure toast library:
|
||||
toastr.options.escapeHtml = true; // Prevent raw HTML inserts
|
||||
|
@ -5,6 +5,8 @@ const ELEMENT_ID = 'loader';
|
||||
/** @type {Popup} */
|
||||
let loaderPopup;
|
||||
|
||||
let preloaderYoinked = false;
|
||||
|
||||
export function showLoader() {
|
||||
// Two loaders don't make sense. Don't await, we can overlay the old loader while it closes
|
||||
if (loaderPopup) loaderPopup.complete(POPUP_RESULT.CANCELLED);
|
||||
@ -21,6 +23,10 @@ export function showLoader() {
|
||||
}
|
||||
|
||||
export async function hideLoader() {
|
||||
// Yoink preloader entirely; it only exists to cover up unstyled content while loading JS
|
||||
// If it's present, we remove it once and then it's gone.
|
||||
yoinkPreloader();
|
||||
|
||||
if (!loaderPopup) {
|
||||
console.warn('There is no loader showing to hide');
|
||||
return Promise.resolve();
|
||||
@ -48,3 +54,8 @@ export async function hideLoader() {
|
||||
});
|
||||
}
|
||||
|
||||
function yoinkPreloader() {
|
||||
if (preloaderYoinked) return;
|
||||
document.getElementById('preloader').remove();
|
||||
preloaderYoinked = true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user