mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-03-13 10:30:14 +01:00
Return to using string type for this_chid
This commit is contained in:
parent
b6af55134a
commit
b2ce76c84c
@ -1378,7 +1378,7 @@ export async function selectCharacterById(id) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (selected_group || this_chid !== id) {
|
||||
if (selected_group || String(this_chid) !== String(id)) {
|
||||
//if clicked on a different character from what was currently selected
|
||||
if (!is_send_press) {
|
||||
await clearChat();
|
||||
@ -1386,7 +1386,7 @@ export async function selectCharacterById(id) {
|
||||
resetSelectedGroup();
|
||||
this_edit_mes_id = undefined;
|
||||
selected_button = 'character_edit';
|
||||
this_chid = id;
|
||||
setCharacterId(id);
|
||||
chat.length = 0;
|
||||
chat_metadata = {};
|
||||
await getChat();
|
||||
@ -6233,8 +6233,25 @@ export function setExternalAbortController(controller) {
|
||||
abortController = controller;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a character array index.
|
||||
* @param {number|string|undefined} value
|
||||
*/
|
||||
export function setCharacterId(value) {
|
||||
this_chid = value;
|
||||
switch (typeof value) {
|
||||
case 'number':
|
||||
this_chid = String(value);
|
||||
break;
|
||||
case 'string':
|
||||
this_chid = !isNaN(parseInt(value)) ? value : undefined;
|
||||
break;
|
||||
case 'undefined':
|
||||
this_chid = undefined;
|
||||
break;
|
||||
default:
|
||||
console.error('Invalid character ID type:', value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
export function setCharacterName(value) {
|
||||
@ -6350,13 +6367,13 @@ export async function renameCharacter(name = null, { silent = false, renameChats
|
||||
|
||||
if (newChId !== -1) {
|
||||
// Select the character after the renaming
|
||||
this_chid = -1;
|
||||
setCharacterId(undefined);
|
||||
await selectCharacterById(newChId);
|
||||
|
||||
// Async delay to update UI
|
||||
await delay(1);
|
||||
|
||||
if (this_chid === -1) {
|
||||
if (this_chid === undefined) {
|
||||
throw new Error('New character not selected');
|
||||
}
|
||||
|
||||
@ -7658,7 +7675,7 @@ export function select_rm_info(type, charId, previousCharId = null) {
|
||||
if (previousCharId) {
|
||||
const newId = characters.findIndex((x) => x.avatar == previousCharId);
|
||||
if (newId >= 0) {
|
||||
this_chid = newId;
|
||||
setCharacterId(newId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user