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');
|
||||
$('#name_div').removeClass('displayNone');
|
||||
$('#name_div').addClass('displayBlock');
|
||||
$('.open_alternate_greetings').data('chid', undefined);
|
||||
$('#set_character_world').data('chid', undefined);
|
||||
$('.open_alternate_greetings').data('chid', -1);
|
||||
$('#set_character_world').data('chid', -1);
|
||||
setWorldInfoButtonClass(undefined, !!create_save.world);
|
||||
updateFavButtonState(false);
|
||||
checkEmbeddedWorld();
|
||||
@ -8248,7 +8248,7 @@ function updateAlternateGreetingsHintVisibility(root) {
|
||||
function openCharacterWorldPopup() {
|
||||
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.');
|
||||
return;
|
||||
}
|
||||
@ -8380,7 +8380,7 @@ function openAlternateGreetings() {
|
||||
return;
|
||||
} else {
|
||||
// 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 = [];
|
||||
}
|
||||
}
|
||||
@ -8567,7 +8567,7 @@ async function createOrEditCharacter(e) {
|
||||
|
||||
formData.delete('alternate_greetings');
|
||||
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) {
|
||||
formData.append('alternate_greetings', value);
|
||||
}
|
||||
|
@ -4732,7 +4732,7 @@ export function setWorldInfoButtonClass(chid, forceValue = undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!chid) {
|
||||
if (chid === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -4749,7 +4749,7 @@ export function checkEmbeddedWorld(chid) {
|
||||
}
|
||||
|
||||
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
|
||||
const checkKey = `AlertWI_${characters[chid].avatar}`;
|
||||
@ -4783,9 +4783,15 @@ export function checkEmbeddedWorld(chid) {
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -5167,20 +5173,24 @@ jQuery(() => {
|
||||
});
|
||||
|
||||
$('#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');
|
||||
|
||||
if (chid) {
|
||||
const worldName = characters[chid]?.data?.extensions?.world;
|
||||
const hasEmbed = checkEmbeddedWorld(chid);
|
||||
if (worldName && world_names.includes(worldName) && !event.shiftKey) {
|
||||
openWorldInfoEditor(worldName);
|
||||
} else if (hasEmbed && !event.shiftKey) {
|
||||
await importEmbeddedWorldInfo();
|
||||
saveCharacterDebounced();
|
||||
}
|
||||
else {
|
||||
$('#char-management-dropdown').val($('#set_character_world').val()).trigger('change');
|
||||
}
|
||||
if (chid === -1) {
|
||||
openSetWorldMenu();
|
||||
return;
|
||||
}
|
||||
|
||||
const worldName = characters[chid]?.data?.extensions?.world;
|
||||
const hasEmbed = checkEmbeddedWorld(chid);
|
||||
if (worldName && world_names.includes(worldName) && !event.shiftKey) {
|
||||
openWorldInfoEditor(worldName);
|
||||
} else if (hasEmbed && !event.shiftKey) {
|
||||
await importEmbeddedWorldInfo();
|
||||
saveCharacterDebounced();
|
||||
}
|
||||
else {
|
||||
openSetWorldMenu();
|
||||
}
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user