fix toasts and final char selection
| @@ -7299,7 +7299,7 @@ export function select_rm_info(type, charId, previousCharId = null) { | ||
| 7299 | 7299 | // Set a timeout so multiple flashes don't overlap |
| 7300 | 7300 | clearTimeout(importFlashTimeout); |
| 7301 | 7301 | importFlashTimeout = setTimeout(function () { |
| 7302 | 7302 | if (type === 'char_import' || type === 'char_create' || type === 'char_import_no_toast') { |
| 7303 | 7303 | // Find the page at which the character is located |
| 7304 | 7304 | const avatarFileName = charId; |
| 7305 | 7305 | const charData = getEntitiesList({ doFilter: true }); |
| @@ -8865,7 +8865,10 @@ export async function processDroppedFiles(files, data = new Map()) { | ||
| 8865 | 8865 | } |
| 8866 | 8866 | } |
| 8867 | 8867 | |
| 8868 | + if (avatarFileNames.length > 0){ | |
| 8868 | 8869 | await importCharactersTags(avatarFileNames); |
| 8870 | + selectImportedChar(avatarFileNames[avatarFileNames.length - 1]); | |
| 8871 | + } | |
| 8869 | 8872 | } |
| 8870 | 8873 | |
| 8871 | 8874 | /** |
| @@ -8883,6 +8886,18 @@ async function importCharactersTags(avatarFileNames) { | ||
| 8883 | 8886 | } |
| 8884 | 8887 | |
| 8885 | 8888 | /** |
| 8889 | + * Selects the given imported char | |
| 8890 | + * @param {string} charId char to select | |
| 8891 | + */ | |
| 8892 | +function selectImportedChar(charId) { | |
| 8893 | + let oldSelectedChar = null; | |
| 8894 | + if (this_chid !== undefined) { | |
| 8895 | + oldSelectedChar = characters[this_chid].avatar; | |
| 8896 | + } | |
| 8897 | + select_rm_info('char_import_no_toast', charId, oldSelectedChar); | |
| 8898 | +} | |
| 8899 | + | |
| 8900 | +/** | |
| 8886 | 8901 | * Imports a character from a file. |
| 8887 | 8902 | * @param {File} file File to import |
| 8888 | 8903 | * @param {object} [options] - Options |
| @@ -8926,15 +8941,12 @@ async function importCharacter(file, {preserveFileName = '', importTags = false} | ||
| 8926 | 8941 | if (data.file_name !== undefined) { |
| 8927 | 8942 | $('#character_search_bar').val('').trigger('input'); |
| 8928 | 8943 | |
| 8929 | - let oldSelectedChar = null; | |
| 8944 | + toastr.success(t`Character Created: ${String(data.file_name).replace('.png', '')}`); | |
| 8930 | - if (this_chid !== undefined) { | |
| 8931 | - oldSelectedChar = characters[this_chid].avatar; | |
| 8932 | - } | |
| 8933 | - | |
| 8934 | - select_rm_info('char_import', data.file_name, oldSelectedChar); | |
| 8935 | 8945 | let avatarFileName = `${data.file_name}.png`; |
| 8936 | 8946 | if (importTags) { |
| 8937 | 8947 | await importCharactersTags([avatarFileName]); |
| 8948 | + | |
| 8949 | + selectImportedChar(data.file_name); | |
| 8938 | 8950 | } |
| 8939 | 8951 | return avatarFileName; |
| 8940 | 8952 | } |
| @@ -10822,7 +10834,11 @@ jQuery(async function () { | ||
| 10822 | 10834 | avatarFileNames.push(avatarFileName); |
| 10823 | 10835 | } |
| 10824 | 10836 | } |
| 10837 | + | |
| 10838 | + if (avatarFileNames.length > 0){ | |
| 10825 | 10839 | await importCharactersTags(avatarFileNames); |
| 10840 | + selectImportedChar(avatarFileNames[avatarFileNames.length - 1]); | |
| 10841 | + } | |
| 10826 | 10842 | }); |
| 10827 | 10843 | |
| 10828 | 10844 | $('#export_button').on('click', function () { |