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);
|
xhr.setRequestHeader("X-CSRF-Token", token);
|
||||||
});
|
});
|
||||||
|
|
||||||
///// initialization protocol ////////
|
async function firstLoadInit() {
|
||||||
$.get("/csrf-token").then(async (data) => {
|
try {
|
||||||
token = data.token;
|
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();
|
getSystemMessages();
|
||||||
sendSystemMessage(system_message_types.WELCOME);
|
sendSystemMessage(system_message_types.WELCOME);
|
||||||
await readSecretState();
|
await readSecretState();
|
||||||
@ -713,7 +720,10 @@ $.get("/csrf-token").then(async (data) => {
|
|||||||
await getUserAvatars();
|
await getUserAvatars();
|
||||||
await getCharacters();
|
await getCharacters();
|
||||||
await getBackgrounds();
|
await getBackgrounds();
|
||||||
});
|
initAuthorsNote();
|
||||||
|
initPersonas();
|
||||||
|
initRossMods();
|
||||||
|
}
|
||||||
|
|
||||||
function checkOnlineStatus() {
|
function checkOnlineStatus() {
|
||||||
///////// REMOVED LINES THAT DUPLICATE RA_CHeckOnlineStatus FEATURES
|
///////// REMOVED LINES THAT DUPLICATE RA_CHeckOnlineStatus FEATURES
|
||||||
@ -4661,9 +4671,6 @@ export async function getUserAvatars() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function highlightSelectedAvatar() {
|
function highlightSelectedAvatar() {
|
||||||
$("#user_avatar_block").find(".avatar").removeClass("selected");
|
$("#user_avatar_block").find(".avatar").removeClass("selected");
|
||||||
$("#user_avatar_block")
|
$("#user_avatar_block")
|
||||||
@ -4711,7 +4718,6 @@ export function setUserName(value) {
|
|||||||
saveSettings("change_name");
|
saveSettings("change_name");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function setUserAvatar() {
|
function setUserAvatar() {
|
||||||
user_avatar = $(this).attr("imgfile");
|
user_avatar = $(this).attr("imgfile");
|
||||||
reloadUserAvatar();
|
reloadUserAvatar();
|
||||||
@ -4775,8 +4781,6 @@ async function uploadUserAvatar(e) {
|
|||||||
$("#form_upload_avatar").trigger("reset");
|
$("#form_upload_avatar").trigger("reset");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async function doOnboarding(avatarId) {
|
async function doOnboarding(avatarId) {
|
||||||
let simpleUiMode = false;
|
let simpleUiMode = false;
|
||||||
const template = $('#onboarding_template .onboarding');
|
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
|
// Common code for message editor done and auto-save
|
||||||
function updateMessage(div) {
|
function updateMessage(div) {
|
||||||
const mesBlock = div.closest(".mes_block");
|
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.
|
* Function to delete a character from UI after character deletion API success.
|
||||||
* It manages necessary UI changes such as closing advanced editing popup, unsetting
|
* It manages necessary UI changes such as closing advanced editing popup, unsetting
|
||||||
@ -6952,8 +6943,7 @@ function doTogglePanels() {
|
|||||||
$("#option_settings").trigger('click')
|
$("#option_settings").trigger('click')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
jQuery(async function () {
|
||||||
$(document).ready(function () {
|
|
||||||
|
|
||||||
if (isMobile() === true) {
|
if (isMobile() === true) {
|
||||||
console.debug('hiding movingUI and sheldWidth toggles for mobile')
|
console.debug('hiding movingUI and sheldWidth toggles for mobile')
|
||||||
@ -7241,6 +7231,7 @@ $(document).ready(function () {
|
|||||||
$("#character_popup").css("display", "none");
|
$("#character_popup").css("display", "none");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#character_cross").click(function () {
|
$("#character_cross").click(function () {
|
||||||
is_advanced_char_open = false;
|
is_advanced_char_open = false;
|
||||||
$("#character_popup").transition({
|
$("#character_popup").transition({
|
||||||
@ -7250,10 +7241,12 @@ $(document).ready(function () {
|
|||||||
});
|
});
|
||||||
setTimeout(function () { $("#character_popup").css("display", "none"); }, 200);
|
setTimeout(function () { $("#character_popup").css("display", "none"); }, 200);
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#character_popup_ok").click(function () {
|
$("#character_popup_ok").click(function () {
|
||||||
is_advanced_char_open = false;
|
is_advanced_char_open = false;
|
||||||
$("#character_popup").css("display", "none");
|
$("#character_popup").css("display", "none");
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#dialogue_popup_ok").click(async function (e) {
|
$("#dialogue_popup_ok").click(async function (e) {
|
||||||
$("#shadow_popup").transition({
|
$("#shadow_popup").transition({
|
||||||
opacity: 0,
|
opacity: 0,
|
||||||
@ -7348,6 +7341,7 @@ $(document).ready(function () {
|
|||||||
dialogueResolve = null;
|
dialogueResolve = null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#dialogue_popup_cancel").click(function (e) {
|
$("#dialogue_popup_cancel").click(function (e) {
|
||||||
$("#shadow_popup").transition({
|
$("#shadow_popup").transition({
|
||||||
opacity: 0,
|
opacity: 0,
|
||||||
@ -7880,8 +7874,6 @@ $(document).ready(function () {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const sliders = [
|
const sliders = [
|
||||||
{
|
{
|
||||||
sliderId: "#amount_gen",
|
sliderId: "#amount_gen",
|
||||||
@ -7971,7 +7963,6 @@ $(document).ready(function () {
|
|||||||
$('#rawPromptPopup').toggle();
|
$('#rawPromptPopup').toggle();
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
//********************
|
//********************
|
||||||
//***Message Editor***
|
//***Message Editor***
|
||||||
$(document).on("click", ".mes_edit", async function () {
|
$(document).on("click", ".mes_edit", async function () {
|
||||||
@ -8218,7 +8209,6 @@ $(document).ready(function () {
|
|||||||
setUserName($('#your_name').val());
|
setUserName($('#your_name').val());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
$('#sync_name_button').on('click', async function () {
|
$('#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');
|
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_button").click(function () {
|
||||||
$("#character_import_file").click();
|
$("#character_import_file").click();
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#character_import_file").on("change", function (e) {
|
$("#character_import_file").on("change", function (e) {
|
||||||
$("#rm_info_avatar").html("");
|
$("#rm_info_avatar").html("");
|
||||||
if (!e.target.files.length) {
|
if (!e.target.files.length) {
|
||||||
@ -8273,10 +8264,12 @@ $(document).ready(function () {
|
|||||||
importCharacter(file);
|
importCharacter(file);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#export_button").on('click', function (e) {
|
$("#export_button").on('click', function (e) {
|
||||||
$('#export_format_popup').toggle();
|
$('#export_format_popup').toggle();
|
||||||
exportPopper.update();
|
exportPopper.update();
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on('click', '.export_format', async function () {
|
$(document).on('click', '.export_format', async function () {
|
||||||
const format = $(this).data('format');
|
const format = $(this).data('format');
|
||||||
|
|
||||||
@ -8642,7 +8635,6 @@ $(document).ready(function () {
|
|||||||
$("#char-management-dropdown").prop('selectedIndex', 0);
|
$("#char-management-dropdown").prop('selectedIndex', 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
$(document).on('click', '.mes_img_enlarge', enlargeMessageImage);
|
$(document).on('click', '.mes_img_enlarge', enlargeMessageImage);
|
||||||
$(document).on('click', '.mes_img_delete', deleteMessageImage);
|
$(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
|
// Added here to prevent execution before script.js is loaded and get rid of quirky timeouts
|
||||||
initAuthorsNote();
|
await firstLoadInit();
|
||||||
initRossMods();
|
|
||||||
initPersonas();
|
|
||||||
|
|
||||||
registerDebugFunction('backfillTokenCounts', 'Backfill token counters',
|
registerDebugFunction('backfillTokenCounts', 'Backfill token counters',
|
||||||
`Recalculates token counts of all messages in the current chat to refresh the counters.
|
`Recalculates token counts of all messages in the current chat to refresh the counters.
|
||||||
|
Reference in New Issue
Block a user