added tag import back into importCharacter

96cd683d0eb1f772d1c585c8452a6a3bc3bf0fee

d-ber <davide.bertalero@studenti.unimi.it>

1 files changed, +11 -7Showing whitespace changes
public/script.js+11 -7
@@ -8856,7 +8856,7 @@ export async function processDroppedFiles(files, data = new Map()) {
88568856 const extension = file.name.split('.').pop().toLowerCase();
88578857 if (allowedMimeTypes.some(x => file.type.startsWith(x)) || allowedExtensions.includes(extension)) {
88588858 const preservedName = data instanceof Map && data.get(file);
88598859 const avatarFileName = await importCharacter(file, {preserveFileName: preservedName});
88608860 if (avatarFileName !== undefined){
88618861 avatarFileNames.push(avatarFileName);
88628862 }
@@ -8865,14 +8865,14 @@ export async function processDroppedFiles(files, data = new Map()) {
88658865 }
88668866 }
88678867
88688868 await ImportMultipleCharactersTagsImportCharactersTags(avatarFileNames);
88698869}
88708870
88718871/**
88728872 * Imports tags for the given characters
88738873 * @param {string[]} avatarFileNames character avatar filenames whose tags are to import
88748874 */
88758875async function ImportMultipleCharactersTagsImportCharactersTags(avatarFileNames) {
88768876 await getCharacters();
88778877 const currentContext = getContext();
88788878 for (let i = 0; i < avatarFileNames.length; i++) {
@@ -8886,10 +8886,12 @@ async function ImportMultipleCharactersTags(avatarFileNames) {
88868886/**
88878887 * Imports a character from a file.
88888888 * @param {File} file File to import
88898889 * @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
88908892 * @returns {Promise<string>}
88918893 */
88928894async function importCharacter(file, {preserveFileName = '', importTags = false} = {}) {
88938895 if (is_group_generating || is_send_press) {
88948896 toastr.error(t`Cannot import characters while generating. Stop the request and try again.`, t`Import aborted`);
88958897 throw new Error('Cannot import character while generating');
@@ -8932,6 +8934,9 @@ async function importCharacter(file, preserveFileName = '') {
89328934
89338935 select_rm_info('char_import', data.file_name, oldSelectedChar);
89348936 let avatarFileName = `${data.file_name}.png`;
8937+ if (importTags) {
8938+ ImportCharactersTags([avatarFileName])
8939+ }
89358940 return avatarFileName;
89368941 }
89378942}
@@ -10818,8 +10823,7 @@ jQuery(async function () {
1081810823 avatarFileNames.push(avatarFileName);
1081910824 }
1082010825 }
10821-
10826+ await ImportCharactersTags(avatarFileNames);
10822- await ImportMultipleCharactersTags(avatarFileNames);
1082310827 });
1082410828
1082510829 $('#export_button').on('click', function () {