Fix world info binding and alt.greetings editor for first char in the list Possibly fixes #3579

2df140a6a9ef0cab65db3c7f8a2390a0b56345e0

Cohee <18619528+Cohee1207@users.noreply.github.com>

2 files changed, +22 -12Showing whitespace changes
public/script.js+5 -5
@@ -7791,8 +7791,8 @@ function select_rm_create() {
77917791 $('#renameCharButton').css('display', 'none');
77927792 $('#name_div').removeClass('displayNone');
77937793 $('#name_div').addClass('displayBlock');
77947794 $('.open_alternate_greetings').data('chid', undefined-1);
77957795 $('#set_character_world').data('chid', undefined-1);
77967796 setWorldInfoButtonClass(undefined, !!create_save.world);
77977797 updateFavButtonState(false);
77987798 checkEmbeddedWorld();
@@ -8248,7 +8248,7 @@ function updateAlternateGreetingsHintVisibility(root) {
82488248function openCharacterWorldPopup() {
82498249 const chid = $('#set_character_world').data('chid');
82508250
82518251 if (menu_type != 'create' && chid === undefined) {
82528252 toastr.error('Does not have an Id for this character in world select menu.');
82538253 return;
82548254 }
@@ -8380,7 +8380,7 @@ function openAlternateGreetings() {
83808380 return;
83818381 } else {
83828382 // If the character does not have alternate greetings, create an empty array
83838383 if (characters[chid] && !Array.isArray(characters[chid].data.alternate_greetings) == false) {
83848384 characters[chid].data.alternate_greetings = [];
83858385 }
83868386 }
@@ -8567,7 +8567,7 @@ async function createOrEditCharacter(e) {
85678567
85688568 formData.delete('alternate_greetings');
85698569 const chid = $('.open_alternate_greetings').data('chid');
85708570 if (characters[chid] && Array.isArray(characters[chid]?.data?.alternate_greetings)) {
85718571 for (const value of characters[chid].data.alternate_greetings) {
85728572 formData.append('alternate_greetings', value);
85738573 }
public/scripts/world-info.js+17 -7
@@ -4732,7 +4732,7 @@ export function setWorldInfoButtonClass(chid, forceValue = undefined) {
47324732 return;
47334733 }
47344734
47354735 if (!chid === undefined) {
47364736 return;
47374737 }
47384738
@@ -4749,7 +4749,7 @@ export function checkEmbeddedWorld(chid) {
47494749 }
47504750
47514751 if (characters[chid]?.data?.character_book) {
47524752 $('#import_character_info').data('data-chid', chid).show();
47534753
47544754 // Only show the alert once per character
47554755 const checkKey = `AlertWI_${characters[chid].avatar}`;
@@ -4783,9 +4783,15 @@ export function checkEmbeddedWorld(chid) {
47834783}
47844784
47854785export async function importEmbeddedWorldInfo(skipPopup = false) {
47864786 const chid = $('#import_character_info').data('data-chid');
47874787
47884788 if (chid === undefined || chid === -1) {
4789+ return;
4790+ }
4791+
4792+ const hasEmbed = checkEmbeddedWorld(chid);
4793+
4794+ if (!hasEmbed) {
47894795 return;
47904796 }
47914797
@@ -5167,9 +5173,14 @@ jQuery(() => {
51675173 });
51685174
51695175 $('#world_button').on('click', async function (event) {
5176+ const openSetWorldMenu = () => $('#char-management-dropdown').val($('#set_character_world').val()).trigger('change');
51705177 const chid = $('#set_character_world').data('chid');
51715178
51725179 if (chid === -1) {
5180+ openSetWorldMenu();
5181+ return;
5182+ }
5183+
51735184 const worldName = characters[chid]?.data?.extensions?.world;
51745185 const hasEmbed = checkEmbeddedWorld(chid);
51755186 if (worldName && world_names.includes(worldName) && !event.shiftKey) {
@@ -5179,8 +5190,7 @@ jQuery(() => {
51795190 saveCharacterDebounced();
51805191 }
51815192 else {
5182- $('#char-management-dropdown').val($('#set_character_world').val()).trigger('change');
5193+ openSetWorldMenu();
5183- }
51845194 }
51855195 });
51865196