#1250 Fix multiple card import tags
This commit is contained in:
parent
2a16d24760
commit
59af85ce1c
|
@ -6970,7 +6970,7 @@ function connectAPISlash(_, text) {
|
||||||
toastr.info(`API set to ${text}, trying to connect..`);
|
toastr.info(`API set to ${text}, trying to connect..`);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function processDroppedFiles(files) {
|
export async function processDroppedFiles(files) {
|
||||||
const allowedMimeTypes = [
|
const allowedMimeTypes = [
|
||||||
'application/json',
|
'application/json',
|
||||||
'image/png',
|
'image/png',
|
||||||
|
@ -6978,14 +6978,14 @@ export function processDroppedFiles(files) {
|
||||||
|
|
||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
if (allowedMimeTypes.includes(file.type)) {
|
if (allowedMimeTypes.includes(file.type)) {
|
||||||
importCharacter(file);
|
await importCharacter(file);
|
||||||
} else {
|
} else {
|
||||||
toastr.warning('Unsupported file type: ' + file.name);
|
toastr.warning('Unsupported file type: ' + file.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function importCharacter(file) {
|
async function importCharacter(file) {
|
||||||
const ext = file.name.match(/\.(\w+)$/);
|
const ext = file.name.match(/\.(\w+)$/);
|
||||||
if (
|
if (
|
||||||
!ext ||
|
!ext ||
|
||||||
|
@ -7000,17 +7000,16 @@ function importCharacter(file) {
|
||||||
formData.append('avatar', file);
|
formData.append('avatar', file);
|
||||||
formData.append('file_type', format);
|
formData.append('file_type', format);
|
||||||
|
|
||||||
jQuery.ajax({
|
const data = await jQuery.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: "/importcharacter",
|
url: "/importcharacter",
|
||||||
data: formData,
|
data: formData,
|
||||||
async: false,
|
async: true,
|
||||||
beforeSend: function () {
|
|
||||||
},
|
|
||||||
cache: false,
|
cache: false,
|
||||||
contentType: false,
|
contentType: false,
|
||||||
processData: false,
|
processData: false,
|
||||||
success: async function (data) {
|
});
|
||||||
|
|
||||||
if (data.error) {
|
if (data.error) {
|
||||||
toastr.error('The file is likely invalid or corrupted.', 'Could not import character');
|
toastr.error('The file is likely invalid or corrupted.', 'Could not import character');
|
||||||
return;
|
return;
|
||||||
|
@ -7033,11 +7032,6 @@ function importCharacter(file) {
|
||||||
await importTags(importedCharacter);
|
await importTags(importedCharacter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
error: function (jqXHR, exception) {
|
|
||||||
$("#create_button").removeAttr("disabled");
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function importFromURL(items, files) {
|
async function importFromURL(items, files) {
|
||||||
|
@ -8966,7 +8960,7 @@ jQuery(async function () {
|
||||||
|
|
||||||
switch (customContentType) {
|
switch (customContentType) {
|
||||||
case 'character':
|
case 'character':
|
||||||
processDroppedFiles([file]);
|
await processDroppedFiles([file]);
|
||||||
break;
|
break;
|
||||||
case 'lorebook':
|
case 'lorebook':
|
||||||
await importWorldInfo(file);
|
await importWorldInfo(file);
|
||||||
|
@ -9029,7 +9023,7 @@ jQuery(async function () {
|
||||||
if (!files.length) {
|
if (!files.length) {
|
||||||
await importFromURL(event.originalEvent.dataTransfer.items, files);
|
await importFromURL(event.originalEvent.dataTransfer.items, files);
|
||||||
}
|
}
|
||||||
processDroppedFiles(files);
|
await processDroppedFiles(files);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue