mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-03-13 18:40:11 +01:00
Fix world info binding and alt.greetings editor for first char in the list
Possibly fixes #3579
This commit is contained in:
parent
eac0d04fd3
commit
2df140a6a9
@ -7791,8 +7791,8 @@ function select_rm_create() {
|
|||||||
$('#renameCharButton').css('display', 'none');
|
$('#renameCharButton').css('display', 'none');
|
||||||
$('#name_div').removeClass('displayNone');
|
$('#name_div').removeClass('displayNone');
|
||||||
$('#name_div').addClass('displayBlock');
|
$('#name_div').addClass('displayBlock');
|
||||||
$('.open_alternate_greetings').data('chid', undefined);
|
$('.open_alternate_greetings').data('chid', -1);
|
||||||
$('#set_character_world').data('chid', undefined);
|
$('#set_character_world').data('chid', -1);
|
||||||
setWorldInfoButtonClass(undefined, !!create_save.world);
|
setWorldInfoButtonClass(undefined, !!create_save.world);
|
||||||
updateFavButtonState(false);
|
updateFavButtonState(false);
|
||||||
checkEmbeddedWorld();
|
checkEmbeddedWorld();
|
||||||
@ -8248,7 +8248,7 @@ function updateAlternateGreetingsHintVisibility(root) {
|
|||||||
function openCharacterWorldPopup() {
|
function openCharacterWorldPopup() {
|
||||||
const chid = $('#set_character_world').data('chid');
|
const chid = $('#set_character_world').data('chid');
|
||||||
|
|
||||||
if (menu_type != 'create' && chid == undefined) {
|
if (menu_type != 'create' && chid === undefined) {
|
||||||
toastr.error('Does not have an Id for this character in world select menu.');
|
toastr.error('Does not have an Id for this character in world select menu.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -8380,7 +8380,7 @@ function openAlternateGreetings() {
|
|||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
// If the character does not have alternate greetings, create an empty array
|
// If the character does not have alternate greetings, create an empty array
|
||||||
if (chid && Array.isArray(characters[chid].data.alternate_greetings) == false) {
|
if (characters[chid] && !Array.isArray(characters[chid].data.alternate_greetings)) {
|
||||||
characters[chid].data.alternate_greetings = [];
|
characters[chid].data.alternate_greetings = [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -8567,7 +8567,7 @@ async function createOrEditCharacter(e) {
|
|||||||
|
|
||||||
formData.delete('alternate_greetings');
|
formData.delete('alternate_greetings');
|
||||||
const chid = $('.open_alternate_greetings').data('chid');
|
const chid = $('.open_alternate_greetings').data('chid');
|
||||||
if (chid && Array.isArray(characters[chid]?.data?.alternate_greetings)) {
|
if (characters[chid] && Array.isArray(characters[chid]?.data?.alternate_greetings)) {
|
||||||
for (const value of characters[chid].data.alternate_greetings) {
|
for (const value of characters[chid].data.alternate_greetings) {
|
||||||
formData.append('alternate_greetings', value);
|
formData.append('alternate_greetings', value);
|
||||||
}
|
}
|
||||||
|
@ -4732,7 +4732,7 @@ export function setWorldInfoButtonClass(chid, forceValue = undefined) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!chid) {
|
if (chid === undefined) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4749,7 +4749,7 @@ export function checkEmbeddedWorld(chid) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (characters[chid]?.data?.character_book) {
|
if (characters[chid]?.data?.character_book) {
|
||||||
$('#import_character_info').data('data-chid', chid).show();
|
$('#import_character_info').data('chid', chid).show();
|
||||||
|
|
||||||
// Only show the alert once per character
|
// Only show the alert once per character
|
||||||
const checkKey = `AlertWI_${characters[chid].avatar}`;
|
const checkKey = `AlertWI_${characters[chid].avatar}`;
|
||||||
@ -4783,9 +4783,15 @@ export function checkEmbeddedWorld(chid) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function importEmbeddedWorldInfo(skipPopup = false) {
|
export async function importEmbeddedWorldInfo(skipPopup = false) {
|
||||||
const chid = $('#import_character_info').data('data-chid');
|
const chid = $('#import_character_info').data('chid');
|
||||||
|
|
||||||
if (chid === undefined) {
|
if (chid === undefined || chid === -1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const hasEmbed = checkEmbeddedWorld(chid);
|
||||||
|
|
||||||
|
if (!hasEmbed) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5167,20 +5173,24 @@ jQuery(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$('#world_button').on('click', async function (event) {
|
$('#world_button').on('click', async function (event) {
|
||||||
|
const openSetWorldMenu = () => $('#char-management-dropdown').val($('#set_character_world').val()).trigger('change');
|
||||||
const chid = $('#set_character_world').data('chid');
|
const chid = $('#set_character_world').data('chid');
|
||||||
|
|
||||||
if (chid) {
|
if (chid === -1) {
|
||||||
const worldName = characters[chid]?.data?.extensions?.world;
|
openSetWorldMenu();
|
||||||
const hasEmbed = checkEmbeddedWorld(chid);
|
return;
|
||||||
if (worldName && world_names.includes(worldName) && !event.shiftKey) {
|
}
|
||||||
openWorldInfoEditor(worldName);
|
|
||||||
} else if (hasEmbed && !event.shiftKey) {
|
const worldName = characters[chid]?.data?.extensions?.world;
|
||||||
await importEmbeddedWorldInfo();
|
const hasEmbed = checkEmbeddedWorld(chid);
|
||||||
saveCharacterDebounced();
|
if (worldName && world_names.includes(worldName) && !event.shiftKey) {
|
||||||
}
|
openWorldInfoEditor(worldName);
|
||||||
else {
|
} else if (hasEmbed && !event.shiftKey) {
|
||||||
$('#char-management-dropdown').val($('#set_character_world').val()).trigger('change');
|
await importEmbeddedWorldInfo();
|
||||||
}
|
saveCharacterDebounced();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
openSetWorldMenu();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user