| 8851 | 8851 | 'charx', |
| 8852 | 8852 | ]; |
| 8853 | 8853 | |
| 8854 | + const avatarFileNames = []; |
| 8854 | 8855 | for (const file of files) { |
| 8855 | 8856 | const extension = file.name.split('.').pop().toLowerCase(); |
| 8856 | 8857 | if (allowedMimeTypes.some(x => file.type.startsWith(x)) || allowedExtensions.includes(extension)) { |
| 8857 | 8858 | const preservedName = data instanceof Map && data.get(file); |
| 8858 | 8859 | const avatarFileName = await importCharacter(file, preservedName); |
| 8860 | + if (avatarFileName !== undefined){ |
| 8861 | + avatarFileNames.push(avatarFileName); |
| 8862 | + } |
| 8859 | 8863 | } else { |
| 8860 | 8864 | toastr.warning(t`Unsupported file type: ` + file.name); |
| 8861 | 8865 | } |
| 8862 | 8866 | } |
| 8867 | + |
| 8868 | + await ImportMultipleCharactersTags(avatarFileNames); |
| 8869 | +} |
| 8870 | + |
| 8871 | +/** |
| 8872 | + * Imports tags for the given characters |
| 8873 | + * @param {string[]} avatarFileNames character avatar filenames whose tags are to import |
| 8874 | + */ |
| 8875 | +async function ImportMultipleCharactersTags(avatarFileNames) { |
| 8876 | + await getCharacters(); |
| 8877 | + const currentContext = getContext(); |
| 8878 | + for (let i = 0; i < avatarFileNames.length; i++) { |
| 8879 | + if (power_user.tag_import_setting !== tag_import_setting.NONE) { |
| 8880 | + const importedCharacter = currentContext.characters.find(character => character.avatar === avatarFileNames[i]); |
| 8881 | + await importTags(importedCharacter); |
| 8882 | + } |
| 8883 | + } |
| 8863 | 8884 | } |
| 8864 | 8885 | |
| 8865 | 8886 | /** |
| 8866 | 8887 | * Imports a character from a file. |
| 8867 | 8888 | * @param {File} file File to import |
| 8868 | 8889 | * @param {string?} preserveFileName Whether to preserve original file name |
| 8869 | 8890 | * @returns {Promise<voidstring>} |
| 8870 | 8891 | */ |
| 8871 | 8892 | async function importCharacter(file, preserveFileName = '') { |
| 8872 | 8893 | if (is_group_generating || is_send_press) { |