mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
fix toasts and final char selection
This commit is contained in:
@@ -7299,7 +7299,7 @@ export function select_rm_info(type, charId, previousCharId = null) {
|
|||||||
// Set a timeout so multiple flashes don't overlap
|
// Set a timeout so multiple flashes don't overlap
|
||||||
clearTimeout(importFlashTimeout);
|
clearTimeout(importFlashTimeout);
|
||||||
importFlashTimeout = setTimeout(function () {
|
importFlashTimeout = setTimeout(function () {
|
||||||
if (type === 'char_import' || type === 'char_create') {
|
if (type === 'char_import' || type === 'char_create' || type === 'char_import_no_toast') {
|
||||||
// Find the page at which the character is located
|
// Find the page at which the character is located
|
||||||
const avatarFileName = charId;
|
const avatarFileName = charId;
|
||||||
const charData = getEntitiesList({ doFilter: true });
|
const charData = getEntitiesList({ doFilter: true });
|
||||||
@@ -8865,7 +8865,10 @@ export async function processDroppedFiles(files, data = new Map()) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (avatarFileNames.length > 0){
|
||||||
await importCharactersTags(avatarFileNames);
|
await importCharactersTags(avatarFileNames);
|
||||||
|
selectImportedChar(avatarFileNames[avatarFileNames.length - 1]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -8882,6 +8885,18 @@ async function importCharactersTags(avatarFileNames) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Selects the given imported char
|
||||||
|
* @param {string} charId char to select
|
||||||
|
*/
|
||||||
|
function selectImportedChar(charId) {
|
||||||
|
let oldSelectedChar = null;
|
||||||
|
if (this_chid !== undefined) {
|
||||||
|
oldSelectedChar = characters[this_chid].avatar;
|
||||||
|
}
|
||||||
|
select_rm_info('char_import_no_toast', charId, oldSelectedChar);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Imports a character from a file.
|
* Imports a character from a file.
|
||||||
* @param {File} file File to import
|
* @param {File} file File to import
|
||||||
@@ -8926,15 +8941,12 @@ async function importCharacter(file, {preserveFileName = '', importTags = false}
|
|||||||
if (data.file_name !== undefined) {
|
if (data.file_name !== undefined) {
|
||||||
$('#character_search_bar').val('').trigger('input');
|
$('#character_search_bar').val('').trigger('input');
|
||||||
|
|
||||||
let oldSelectedChar = null;
|
toastr.success(t`Character Created: ${String(data.file_name).replace('.png', '')}`);
|
||||||
if (this_chid !== undefined) {
|
|
||||||
oldSelectedChar = characters[this_chid].avatar;
|
|
||||||
}
|
|
||||||
|
|
||||||
select_rm_info('char_import', data.file_name, oldSelectedChar);
|
|
||||||
let avatarFileName = `${data.file_name}.png`;
|
let avatarFileName = `${data.file_name}.png`;
|
||||||
if (importTags) {
|
if (importTags) {
|
||||||
await importCharactersTags([avatarFileName])
|
await importCharactersTags([avatarFileName]);
|
||||||
|
|
||||||
|
selectImportedChar(data.file_name);
|
||||||
}
|
}
|
||||||
return avatarFileName;
|
return avatarFileName;
|
||||||
}
|
}
|
||||||
@@ -10822,7 +10834,11 @@ jQuery(async function () {
|
|||||||
avatarFileNames.push(avatarFileName);
|
avatarFileNames.push(avatarFileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (avatarFileNames.length > 0){
|
||||||
await importCharactersTags(avatarFileNames);
|
await importCharactersTags(avatarFileNames);
|
||||||
|
selectImportedChar(avatarFileNames[avatarFileNames.length - 1]);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#export_button').on('click', function () {
|
$('#export_button').on('click', function () {
|
||||||
|
Reference in New Issue
Block a user