mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
#1071 Initialize Ross mods only after the first load completed
This commit is contained in:
@ -702,9 +702,16 @@ $.ajaxPrefilter((options, originalOptions, xhr) => {
|
||||
xhr.setRequestHeader("X-CSRF-Token", token);
|
||||
});
|
||||
|
||||
///// initialization protocol ////////
|
||||
$.get("/csrf-token").then(async (data) => {
|
||||
token = data.token;
|
||||
async function firstLoadInit() {
|
||||
try {
|
||||
const tokenResponse = await fetch('/csrf-token');
|
||||
const tokenData = await tokenResponse.json();
|
||||
token = tokenData.token;
|
||||
} catch {
|
||||
toastr.error("Couldn't get CSRF token. Please refresh the page.", "Error", { timeOut: 0, extendedTimeOut: 0, preventDuplicates: true });
|
||||
throw new Error("Initialization failed");
|
||||
}
|
||||
|
||||
getSystemMessages();
|
||||
sendSystemMessage(system_message_types.WELCOME);
|
||||
await readSecretState();
|
||||
@ -713,7 +720,10 @@ $.get("/csrf-token").then(async (data) => {
|
||||
await getUserAvatars();
|
||||
await getCharacters();
|
||||
await getBackgrounds();
|
||||
});
|
||||
initAuthorsNote();
|
||||
initPersonas();
|
||||
initRossMods();
|
||||
}
|
||||
|
||||
function checkOnlineStatus() {
|
||||
///////// REMOVED LINES THAT DUPLICATE RA_CHeckOnlineStatus FEATURES
|
||||
@ -4661,9 +4671,6 @@ export async function getUserAvatars() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function highlightSelectedAvatar() {
|
||||
$("#user_avatar_block").find(".avatar").removeClass("selected");
|
||||
$("#user_avatar_block")
|
||||
@ -4711,7 +4718,6 @@ export function setUserName(value) {
|
||||
saveSettings("change_name");
|
||||
}
|
||||
|
||||
|
||||
function setUserAvatar() {
|
||||
user_avatar = $(this).attr("imgfile");
|
||||
reloadUserAvatar();
|
||||
@ -4775,8 +4781,6 @@ async function uploadUserAvatar(e) {
|
||||
$("#form_upload_avatar").trigger("reset");
|
||||
}
|
||||
|
||||
|
||||
|
||||
async function doOnboarding(avatarId) {
|
||||
let simpleUiMode = false;
|
||||
const template = $('#onboarding_template .onboarding');
|
||||
@ -5069,18 +5073,6 @@ export function setGenerationParamsFromPreset(preset) {
|
||||
}
|
||||
}
|
||||
|
||||
function setCharacterBlockHeight() {
|
||||
const $children = $("#rm_print_characters_block").children();
|
||||
const originalHeight = $children.length * $children.find(':visible').first().outerHeight();
|
||||
$("#rm_print_characters_block").css('height', originalHeight);
|
||||
//show and hide charlist divs on pageload (causes load lag)
|
||||
//$children.each(function () { setCharListVisible($(this)) });
|
||||
|
||||
|
||||
//delay timer to allow for charlist to populate,
|
||||
//should be set to an onload for rm_print_characters or windows?
|
||||
}
|
||||
|
||||
// Common code for message editor done and auto-save
|
||||
function updateMessage(div) {
|
||||
const mesBlock = div.closest(".mes_block");
|
||||
@ -6918,7 +6910,6 @@ export async function handleDeleteCharacter(popup_type, this_chid, delete_chats)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function to delete a character from UI after character deletion API success.
|
||||
* It manages necessary UI changes such as closing advanced editing popup, unsetting
|
||||
@ -6952,8 +6943,7 @@ function doTogglePanels() {
|
||||
$("#option_settings").trigger('click')
|
||||
}
|
||||
|
||||
|
||||
$(document).ready(function () {
|
||||
jQuery(async function () {
|
||||
|
||||
if (isMobile() === true) {
|
||||
console.debug('hiding movingUI and sheldWidth toggles for mobile')
|
||||
@ -7241,6 +7231,7 @@ $(document).ready(function () {
|
||||
$("#character_popup").css("display", "none");
|
||||
}
|
||||
});
|
||||
|
||||
$("#character_cross").click(function () {
|
||||
is_advanced_char_open = false;
|
||||
$("#character_popup").transition({
|
||||
@ -7250,10 +7241,12 @@ $(document).ready(function () {
|
||||
});
|
||||
setTimeout(function () { $("#character_popup").css("display", "none"); }, 200);
|
||||
});
|
||||
|
||||
$("#character_popup_ok").click(function () {
|
||||
is_advanced_char_open = false;
|
||||
$("#character_popup").css("display", "none");
|
||||
});
|
||||
|
||||
$("#dialogue_popup_ok").click(async function (e) {
|
||||
$("#shadow_popup").transition({
|
||||
opacity: 0,
|
||||
@ -7348,6 +7341,7 @@ $(document).ready(function () {
|
||||
dialogueResolve = null;
|
||||
}
|
||||
});
|
||||
|
||||
$("#dialogue_popup_cancel").click(function (e) {
|
||||
$("#shadow_popup").transition({
|
||||
opacity: 0,
|
||||
@ -7880,8 +7874,6 @@ $(document).ready(function () {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
const sliders = [
|
||||
{
|
||||
sliderId: "#amount_gen",
|
||||
@ -7971,7 +7963,6 @@ $(document).ready(function () {
|
||||
$('#rawPromptPopup').toggle();
|
||||
})
|
||||
|
||||
|
||||
//********************
|
||||
//***Message Editor***
|
||||
$(document).on("click", ".mes_edit", async function () {
|
||||
@ -8218,7 +8209,6 @@ $(document).ready(function () {
|
||||
setUserName($('#your_name').val());
|
||||
});
|
||||
|
||||
|
||||
$('#sync_name_button').on('click', async function () {
|
||||
const confirmation = await callPopup(`<h3>Are you sure?</h3>All user-sent messages in this chat will be attributed to ${name1}.`, 'confirm');
|
||||
|
||||
@ -8263,6 +8253,7 @@ $(document).ready(function () {
|
||||
$("#character_import_button").click(function () {
|
||||
$("#character_import_file").click();
|
||||
});
|
||||
|
||||
$("#character_import_file").on("change", function (e) {
|
||||
$("#rm_info_avatar").html("");
|
||||
if (!e.target.files.length) {
|
||||
@ -8273,10 +8264,12 @@ $(document).ready(function () {
|
||||
importCharacter(file);
|
||||
}
|
||||
});
|
||||
|
||||
$("#export_button").on('click', function (e) {
|
||||
$('#export_format_popup').toggle();
|
||||
exportPopper.update();
|
||||
});
|
||||
|
||||
$(document).on('click', '.export_format', async function () {
|
||||
const format = $(this).data('format');
|
||||
|
||||
@ -8642,7 +8635,6 @@ $(document).ready(function () {
|
||||
$("#char-management-dropdown").prop('selectedIndex', 0);
|
||||
});
|
||||
|
||||
|
||||
$(document).on('click', '.mes_img_enlarge', enlargeMessageImage);
|
||||
$(document).on('click', '.mes_img_delete', deleteMessageImage);
|
||||
|
||||
@ -8845,9 +8837,7 @@ $(document).ready(function () {
|
||||
});
|
||||
|
||||
// Added here to prevent execution before script.js is loaded and get rid of quirky timeouts
|
||||
initAuthorsNote();
|
||||
initRossMods();
|
||||
initPersonas();
|
||||
await firstLoadInit();
|
||||
|
||||
registerDebugFunction('backfillTokenCounts', 'Backfill token counters',
|
||||
`Recalculates token counts of all messages in the current chat to refresh the counters.
|
||||
|
Reference in New Issue
Block a user