Display loader earlier, init toast classes in power-user
| @@ -313,8 +313,6 @@ await new Promise((resolve) => { | ||
| 313 | 313 | } |
| 314 | 314 | }); |
| 315 | 315 | |
| 316 | -//showLoader(); <-- must wait for poweruser (called from firstinit()), so moved it in there | |
| 317 | - | |
| 318 | 316 | // Configure toast library: |
| 319 | 317 | toastr.options.escapeHtml = true; // Prevent raw HTML inserts |
| 320 | 318 | toastr.options.timeOut = 4000; // How long the toast will display without user interaction |
| @@ -968,11 +966,11 @@ async function firstLoadInit() { | ||
| 968 | 966 | const tokenData = await tokenResponse.json(); |
| 969 | 967 | token = tokenData.token; |
| 970 | 968 | } catch { |
| 971 | - hideLoader(); | |
| 972 | 969 | toastr.error(t`Couldn't get CSRF token. Please refresh the page.`, t`Error`, { timeOut: 0, extendedTimeOut: 0, preventDuplicates: true }); |
| 973 | 970 | throw new Error('Initialization failed'); |
| 974 | 971 | } |
| 975 | 972 | |
| 973 | + showLoader(); | |
| 976 | 974 | initLibraryShims(); |
| 977 | 975 | addShowdownPatch(showdown); |
| 978 | 976 | reloadMarkdownProcessor(); |
| @@ -990,7 +988,6 @@ async function firstLoadInit() { | ||
| 990 | 988 | await initPresetManager(); |
| 991 | 989 | await getSystemMessages(); |
| 992 | 990 | await getSettings(); |
| 993 | - showLoader(); | |
| 994 | 991 | initKeyboard(); |
| 995 | 992 | initDynamicStyles(); |
| 996 | 993 | initTags(); |
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | import dialogPolyfill from '../lib/dialog-polyfill.esm.js'; |
| 2 | 2 | import { shouldSendOnEnter } from './RossAscends-mods.js'; |
| 3 | 3 | import { power_user, toastPositionClasses } from './power-user.js'; |
| 4 | 4 | import { removeFromArray, runAfterAnimation, uuidv4 } from './utils.js'; |
| 5 | 5 | |
| 6 | 6 | /** @readonly */ |
| @@ -725,15 +725,6 @@ export function fixToastrForDialogs() { | ||
| 725 | 725 | if (!toastContainer) { |
| 726 | 726 | toastContainer = document.createElement('div'); |
| 727 | 727 | toastContainer.setAttribute('id', 'toast-container'); |
| 728 | - if (power_user.toastr_position) { | |
| 729 | - toastr.options.positionClass = (power_user.toastr_position); | |
| 730 | - } else { | |
| 731 | - console.warn('Did not find poweruser.toastr_position; defaulting to top center'); | |
| 732 | - power_user.toastr_position = 'toast-top-center'; | |
| 733 | - toastr.options.positionClass = (power_user.toastr_position); | |
| 734 | - $(`#toastr_position option[value=${power_user.toastr_position}]`).attr('selected', true); | |
| 735 | - } | |
| 736 | - //if (toastr.options.positionClass) toastContainer.classList.add(toastr.options.positionClass); | |
| 737 | 728 | } |
| 738 | 729 | |
| 739 | 730 | // Check if toastr is already a child. If not, we need to move it inside this dialog. |
| @@ -752,6 +743,7 @@ export function fixToastrForDialogs() { | ||
| 752 | 743 | toastContainer.remove(); |
| 753 | 744 | } else { |
| 754 | 745 | document.body.appendChild(toastContainer); |
| 746 | + toastContainer.classList.remove(...toastPositionClasses); | |
| 755 | 747 | toastContainer.classList.add(toastr.options.positionClass); |
| 756 | 748 | } |
| 757 | 749 | } |
| @@ -52,7 +52,7 @@ import { ARGUMENT_TYPE, SlashCommandArgument, SlashCommandNamedArgument } from ' | ||
| 52 | 52 | import { AUTOCOMPLETE_SELECT_KEY, AUTOCOMPLETE_WIDTH } from './autocomplete/AutoComplete.js'; |
| 53 | 53 | import { SlashCommandEnumValue, enumTypes } from './slash-commands/SlashCommandEnumValue.js'; |
| 54 | 54 | import { commonEnumProviders, enumIcons } from './slash-commands/SlashCommandCommonEnumsProvider.js'; |
| 55 | 55 | import { POPUP_TYPE, callGenericPopup, fixToastrForDialogs } from './popup.js'; |
| 56 | 56 | import { loadSystemPrompts } from './sysprompt.js'; |
| 57 | 57 | import { fuzzySearchCategories } from './filters.js'; |
| 58 | 58 | import { accountStorage } from './util/AccountStorage.js'; |
| @@ -70,6 +70,15 @@ export { | ||
| 70 | 70 | applyPowerUserSettings, |
| 71 | 71 | }; |
| 72 | 72 | |
| 73 | +export const toastPositionClasses = [ | |
| 74 | + 'toast-top-left', | |
| 75 | + 'toast-top-center', | |
| 76 | + 'toast-top-right', | |
| 77 | + 'toast-bottom-left', | |
| 78 | + 'toast-bottom-center', | |
| 79 | + 'toast-bottom-right', | |
| 80 | +]; | |
| 81 | + | |
| 73 | 82 | export const MAX_CONTEXT_DEFAULT = 8192; |
| 74 | 83 | export const MAX_RESPONSE_DEFAULT = 2048; |
| 75 | 84 | const MAX_CONTEXT_UNLOCKED = 512 * 1024; |
| @@ -81,6 +90,7 @@ const maxContextStep = 64; | ||
| 81 | 90 | const defaultStoryString = '{{#if system}}{{system}}\n{{/if}}{{#if description}}{{description}}\n{{/if}}{{#if personality}}{{char}}\'s personality: {{personality}}\n{{/if}}{{#if scenario}}Scenario: {{scenario}}\n{{/if}}{{#if persona}}{{persona}}\n{{/if}}'; |
| 82 | 91 | const defaultExampleSeparator = '***'; |
| 83 | 92 | const defaultChatStart = '***'; |
| 93 | +const defaultToastPosition = 'toast-top-center'; | |
| 84 | 94 | |
| 85 | 95 | const avatar_styles = { |
| 86 | 96 | ROUND: 0, |
| @@ -137,7 +147,7 @@ let power_user = { | ||
| 137 | 147 | fast_ui_mode: true, |
| 138 | 148 | avatar_style: avatar_styles.ROUND, |
| 139 | 149 | chat_display: chat_styles.DEFAULT, |
| 140 | 150 | toastr_position: 'toast-top-center'defaultToastPosition, |
| 141 | 151 | chat_width: 50, |
| 142 | 152 | never_resize_avatars: false, |
| 143 | 153 | show_card_avatar_urls: false, |
| @@ -1046,39 +1056,13 @@ function applyChatDisplay() { | ||
| 1046 | 1056 | } |
| 1047 | 1057 | |
| 1048 | 1058 | function applyToastrPosition() { |
| 1049 | - | |
| 1059 | + if (!toastPositionClasses.includes(power_user.toastr_position)) { | |
| 1050 | - if (!power_user.toastr_position) { | |
| 1060 | + power_user.toastr_position = defaultToastPosition; | |
| 1051 | - power_user.toastr_position = 'toast-top-center'; | |
| 1061 | + console.warn(`applyToastrPosition: invalid toastr position, defaulting to ${defaultToastPosition}`); | |
| 1052 | - console.warn('applyToastrPosition: missing toastr position, defaulting to top-center'); | |
| 1053 | - } | |
| 1054 | - | |
| 1055 | - switch (power_user.toastr_position) { | |
| 1056 | - case 'toast-top-left': { | |
| 1057 | - toastr.options.positionClass = 'toast-top-left'; | |
| 1058 | - break; | |
| 1059 | - } | |
| 1060 | - case 'toast-top-center': { | |
| 1061 | - toastr.options.positionClass = 'toast-top-center'; | |
| 1062 | - break; | |
| 1063 | - } | |
| 1064 | - case 'toast-top-right': { | |
| 1065 | - toastr.options.positionClass = 'toast-top-right'; | |
| 1066 | - break; | |
| 1067 | - } | |
| 1068 | - case 'toast-bottom-left': { | |
| 1069 | - toastr.options.positionClass = 'toast-bottom-left'; | |
| 1070 | - break; | |
| 1071 | - } | |
| 1072 | - case 'toast-bottom-center': { | |
| 1073 | - toastr.options.positionClass = 'toast-bottom-center'; | |
| 1074 | - break; | |
| 1075 | - } | |
| 1076 | - case 'toast-bottom-right': { | |
| 1077 | - toastr.options.positionClass = 'toast-bottom-right'; | |
| 1078 | - break; | |
| 1079 | - } | |
| 1080 | 1062 | } |
| 1081 | 1063 | |
| 1064 | + toastr.options.positionClass = power_user.toastr_position; | |
| 1065 | + fixToastrForDialogs(); | |
| 1082 | 1066 | $('#toastr_position').val(power_user.toastr_position).prop('selected', true); |
| 1083 | 1067 | } |
| 1084 | 1068 | |
| @@ -1739,6 +1723,7 @@ async function loadPowerUserSettings(settings, data) { | ||
| 1739 | 1723 | loadMovingUIState(); |
| 1740 | 1724 | loadCharListState(); |
| 1741 | 1725 | toggleMDHotkeyIconDisplay(); |
| 1726 | + applyToastrPosition(); | |
| 1742 | 1727 | } |
| 1743 | 1728 | |
| 1744 | 1729 | function toggleMDHotkeyIconDisplay() { |