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 | // Configure toast library: | 316 | // Configure toast library: |
| 319 | toastr.options.escapeHtml = true; // Prevent raw HTML inserts | 317 | toastr.options.escapeHtml = true; // Prevent raw HTML inserts |
| 320 | toastr.options.timeOut = 4000; // How long the toast will display without user interaction | 318 | toastr.options.timeOut = 4000; // How long the toast will display without user interaction |
| @@ -968,11 +966,11 @@ async function firstLoadInit() { | |||
| 968 | const tokenData = await tokenResponse.json(); | 966 | const tokenData = await tokenResponse.json(); |
| 969 | token = tokenData.token; | 967 | token = tokenData.token; |
| 970 | } catch { | 968 | } catch { |
| 971 | hideLoader(); | ||
| 972 | toastr.error(t`Couldn't get CSRF token. Please refresh the page.`, t`Error`, { timeOut: 0, extendedTimeOut: 0, preventDuplicates: true }); | 969 | toastr.error(t`Couldn't get CSRF token. Please refresh the page.`, t`Error`, { timeOut: 0, extendedTimeOut: 0, preventDuplicates: true }); |
| 973 | throw new Error('Initialization failed'); | 970 | throw new Error('Initialization failed'); |
| 974 | } | 971 | } |
| 975 | 972 | ||
| 973 | showLoader(); | ||
| 976 | initLibraryShims(); | 974 | initLibraryShims(); |
| 977 | addShowdownPatch(showdown); | 975 | addShowdownPatch(showdown); |
| 978 | reloadMarkdownProcessor(); | 976 | reloadMarkdownProcessor(); |
| @@ -990,7 +988,6 @@ async function firstLoadInit() { | |||
| 990 | await initPresetManager(); | 988 | await initPresetManager(); |
| 991 | await getSystemMessages(); | 989 | await getSystemMessages(); |
| 992 | await getSettings(); | 990 | await getSettings(); |
| 993 | showLoader(); | ||
| 994 | initKeyboard(); | 991 | initKeyboard(); |
| 995 | initDynamicStyles(); | 992 | initDynamicStyles(); |
| 996 | initTags(); | 993 | initTags(); |
| @@ -1,6 +1,6 @@ | |||
| 1 | import dialogPolyfill from '../lib/dialog-polyfill.esm.js'; | 1 | import dialogPolyfill from '../lib/dialog-polyfill.esm.js'; |
| 2 | import { shouldSendOnEnter } from './RossAscends-mods.js'; | 2 | import { shouldSendOnEnter } from './RossAscends-mods.js'; |
| 3 | import { power_user } from './power-user.js'; | 3 | import { power_user, toastPositionClasses } from './power-user.js'; |
| 4 | import { removeFromArray, runAfterAnimation, uuidv4 } from './utils.js'; | 4 | import { removeFromArray, runAfterAnimation, uuidv4 } from './utils.js'; |
| 5 | 5 | ||
| 6 | /** @readonly */ | 6 | /** @readonly */ |
| @@ -725,15 +725,6 @@ export function fixToastrForDialogs() { | |||
| 725 | if (!toastContainer) { | 725 | if (!toastContainer) { |
| 726 | toastContainer = document.createElement('div'); | 726 | toastContainer = document.createElement('div'); |
| 727 | toastContainer.setAttribute('id', 'toast-container'); | 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 | // Check if toastr is already a child. If not, we need to move it inside this dialog. | 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 | toastContainer.remove(); | 743 | toastContainer.remove(); |
| 753 | } else { | 744 | } else { |
| 754 | document.body.appendChild(toastContainer); | 745 | document.body.appendChild(toastContainer); |
| 746 | toastContainer.classList.remove(...toastPositionClasses); | ||
| 755 | toastContainer.classList.add(toastr.options.positionClass); | 747 | toastContainer.classList.add(toastr.options.positionClass); |
| 756 | } | 748 | } |
| 757 | } | 749 | } |
| @@ -52,7 +52,7 @@ import { ARGUMENT_TYPE, SlashCommandArgument, SlashCommandNamedArgument } from ' | |||
| 52 | import { AUTOCOMPLETE_SELECT_KEY, AUTOCOMPLETE_WIDTH } from './autocomplete/AutoComplete.js'; | 52 | import { AUTOCOMPLETE_SELECT_KEY, AUTOCOMPLETE_WIDTH } from './autocomplete/AutoComplete.js'; |
| 53 | import { SlashCommandEnumValue, enumTypes } from './slash-commands/SlashCommandEnumValue.js'; | 53 | import { SlashCommandEnumValue, enumTypes } from './slash-commands/SlashCommandEnumValue.js'; |
| 54 | import { commonEnumProviders, enumIcons } from './slash-commands/SlashCommandCommonEnumsProvider.js'; | 54 | import { commonEnumProviders, enumIcons } from './slash-commands/SlashCommandCommonEnumsProvider.js'; |
| 55 | import { POPUP_TYPE, callGenericPopup } from './popup.js'; | 55 | import { POPUP_TYPE, callGenericPopup, fixToastrForDialogs } from './popup.js'; |
| 56 | import { loadSystemPrompts } from './sysprompt.js'; | 56 | import { loadSystemPrompts } from './sysprompt.js'; |
| 57 | import { fuzzySearchCategories } from './filters.js'; | 57 | import { fuzzySearchCategories } from './filters.js'; |
| 58 | import { accountStorage } from './util/AccountStorage.js'; | 58 | import { accountStorage } from './util/AccountStorage.js'; |
| @@ -70,6 +70,15 @@ export { | |||
| 70 | applyPowerUserSettings, | 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 | export const MAX_CONTEXT_DEFAULT = 8192; | 82 | export const MAX_CONTEXT_DEFAULT = 8192; |
| 74 | export const MAX_RESPONSE_DEFAULT = 2048; | 83 | export const MAX_RESPONSE_DEFAULT = 2048; |
| 75 | const MAX_CONTEXT_UNLOCKED = 512 * 1024; | 84 | const MAX_CONTEXT_UNLOCKED = 512 * 1024; |
| @@ -81,6 +90,7 @@ const maxContextStep = 64; | |||
| 81 | 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}}'; | 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 | const defaultExampleSeparator = '***'; | 91 | const defaultExampleSeparator = '***'; |
| 83 | const defaultChatStart = '***'; | 92 | const defaultChatStart = '***'; |
| 93 | const defaultToastPosition = 'toast-top-center'; | ||
| 84 | 94 | ||
| 85 | const avatar_styles = { | 95 | const avatar_styles = { |
| 86 | ROUND: 0, | 96 | ROUND: 0, |
| @@ -137,7 +147,7 @@ let power_user = { | |||
| 137 | fast_ui_mode: true, | 147 | fast_ui_mode: true, |
| 138 | avatar_style: avatar_styles.ROUND, | 148 | avatar_style: avatar_styles.ROUND, |
| 139 | chat_display: chat_styles.DEFAULT, | 149 | chat_display: chat_styles.DEFAULT, |
| 140 | toastr_position: 'toast-top-center', | 150 | toastr_position: defaultToastPosition, |
| 141 | chat_width: 50, | 151 | chat_width: 50, |
| 142 | never_resize_avatars: false, | 152 | never_resize_avatars: false, |
| 143 | show_card_avatar_urls: false, | 153 | show_card_avatar_urls: false, |
| @@ -1046,39 +1056,13 @@ function applyChatDisplay() { | |||
| 1046 | } | 1056 | } |
| 1047 | 1057 | ||
| 1048 | function applyToastrPosition() { | 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 | $('#toastr_position').val(power_user.toastr_position).prop('selected', true); | 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 | loadMovingUIState(); | 1723 | loadMovingUIState(); |
| 1740 | loadCharListState(); | 1724 | loadCharListState(); |
| 1741 | toggleMDHotkeyIconDisplay(); | 1725 | toggleMDHotkeyIconDisplay(); |
| 1726 | applyToastrPosition(); | ||
| 1742 | } | 1727 | } |
| 1743 | 1728 | ||
| 1744 | function toggleMDHotkeyIconDisplay() { | 1729 | function toggleMDHotkeyIconDisplay() { |