refac
This commit is contained in:
@@ -779,9 +779,6 @@
|
||||
urls = [urls];
|
||||
}
|
||||
|
||||
// deduplicate URLs
|
||||
urls = [...new Set(urls)];
|
||||
|
||||
// Create file items first
|
||||
const fileItems = urls.map((url) => ({
|
||||
type: 'text',
|
||||
@@ -796,7 +793,6 @@
|
||||
// Display all items at once
|
||||
files = [...files, ...fileItems];
|
||||
|
||||
// Process sequentially (NOT parallel)
|
||||
for (const fileItem of fileItems) {
|
||||
try {
|
||||
const res = isYoutubeUrl(fileItem.url)
|
||||
@@ -811,14 +807,12 @@
|
||||
...fileItem.file
|
||||
};
|
||||
}
|
||||
|
||||
files = [...files];
|
||||
} catch (e) {
|
||||
fileItem.status = 'error';
|
||||
fileItem.error = String(e);
|
||||
files = files.filter((f) => f.name !== url);
|
||||
toast.error(`${e}`);
|
||||
}
|
||||
|
||||
// Force UI reactivity after each file finishes
|
||||
files = [...files];
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -93,6 +93,7 @@
|
||||
|
||||
const i18n = getContext('i18n');
|
||||
|
||||
export let onUpload: Function = (e) => {};
|
||||
export let onChange: Function = () => {};
|
||||
|
||||
export let createMessagePair: Function;
|
||||
|
||||
@@ -15,12 +15,14 @@
|
||||
let url = '';
|
||||
|
||||
const submitHandler = () => {
|
||||
const urls = url
|
||||
let urls = url
|
||||
.split('\n')
|
||||
.map((u) => u.trim())
|
||||
.filter((u) => u !== '')
|
||||
.filter((u) => isValidHttpUrl(u));
|
||||
|
||||
urls = [...new Set(urls)];
|
||||
|
||||
if (urls.length === 0) {
|
||||
toast.error($i18n.t('Please enter a valid URL.'));
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user