added tag import back into importCharacter
| @@ -8856,7 +8856,7 @@ export async function processDroppedFiles(files, data = new Map()) { | ||
| 8856 | 8856 | const extension = file.name.split('.').pop().toLowerCase(); |
| 8857 | 8857 | if (allowedMimeTypes.some(x => file.type.startsWith(x)) || allowedExtensions.includes(extension)) { |
| 8858 | 8858 | const preservedName = data instanceof Map && data.get(file); |
| 8859 | 8859 | const avatarFileName = await importCharacter(file, {preserveFileName: preservedName}); |
| 8860 | 8860 | if (avatarFileName !== undefined){ |
| 8861 | 8861 | avatarFileNames.push(avatarFileName); |
| 8862 | 8862 | } |
| @@ -8865,14 +8865,14 @@ export async function processDroppedFiles(files, data = new Map()) { | ||
| 8865 | 8865 | } |
| 8866 | 8866 | } |
| 8867 | 8867 | |
| 8868 | 8868 | await ImportMultipleCharactersTagsImportCharactersTags(avatarFileNames); |
| 8869 | 8869 | } |
| 8870 | 8870 | |
| 8871 | 8871 | /** |
| 8872 | 8872 | * Imports tags for the given characters |
| 8873 | 8873 | * @param {string[]} avatarFileNames character avatar filenames whose tags are to import |
| 8874 | 8874 | */ |
| 8875 | 8875 | async function ImportMultipleCharactersTagsImportCharactersTags(avatarFileNames) { |
| 8876 | 8876 | await getCharacters(); |
| 8877 | 8877 | const currentContext = getContext(); |
| 8878 | 8878 | for (let i = 0; i < avatarFileNames.length; i++) { |
| @@ -8886,10 +8886,12 @@ async function ImportMultipleCharactersTags(avatarFileNames) { | ||
| 8886 | 8886 | /** |
| 8887 | 8887 | * Imports a character from a file. |
| 8888 | 8888 | * @param {File} file File to import |
| 8889 | 8889 | * @param {string?object} preserveFileName Whether to preserve original[options] file- nameOptions |
| 8890 | + * @param {string} [options.preserveFileName] Whether to preserve original file name | |
| 8891 | + * @param {Boolean} [options.importTags=false] Whether to import tags | |
| 8890 | 8892 | * @returns {Promise<string>} |
| 8891 | 8893 | */ |
| 8892 | 8894 | async function importCharacter(file, {preserveFileName = '', importTags = false} = {}) { |
| 8893 | 8895 | if (is_group_generating || is_send_press) { |
| 8894 | 8896 | toastr.error(t`Cannot import characters while generating. Stop the request and try again.`, t`Import aborted`); |
| 8895 | 8897 | throw new Error('Cannot import character while generating'); |
| @@ -8932,6 +8934,9 @@ async function importCharacter(file, preserveFileName = '') { | ||
| 8932 | 8934 | |
| 8933 | 8935 | select_rm_info('char_import', data.file_name, oldSelectedChar); |
| 8934 | 8936 | let avatarFileName = `${data.file_name}.png`; |
| 8937 | + if (importTags) { | |
| 8938 | + ImportCharactersTags([avatarFileName]) | |
| 8939 | + } | |
| 8935 | 8940 | return avatarFileName; |
| 8936 | 8941 | } |
| 8937 | 8942 | } |
| @@ -10818,8 +10823,7 @@ jQuery(async function () { | ||
| 10818 | 10823 | avatarFileNames.push(avatarFileName); |
| 10819 | 10824 | } |
| 10820 | 10825 | } |
| 10821 | - | |
| 10826 | + await ImportCharactersTags(avatarFileNames); | |
| 10822 | - await ImportMultipleCharactersTags(avatarFileNames); | |
| 10823 | 10827 | }); |
| 10824 | 10828 | |
| 10825 | 10829 | $('#export_button').on('click', function () { |