mirror of
https://github.com/open-webui/open-webui
synced 2025-02-26 07:09:07 +00:00
refac: file should not have 'uploaded' status
This commit is contained in:
parent
6681df29d2
commit
c9ed934d0b
@ -1,6 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { toast } from 'svelte-sonner';
|
import { toast } from 'svelte-sonner';
|
||||||
import { v4 as uuidv4 } from 'uuid';
|
|
||||||
import { onMount, tick, getContext } from 'svelte';
|
import { onMount, tick, getContext } from 'svelte';
|
||||||
import {
|
import {
|
||||||
type Model,
|
type Model,
|
||||||
@ -99,7 +98,6 @@
|
|||||||
|
|
||||||
const uploadFileHandler = async (file) => {
|
const uploadFileHandler = async (file) => {
|
||||||
console.log(file);
|
console.log(file);
|
||||||
const fileId = uuidv4();
|
|
||||||
|
|
||||||
// Check if the file is an audio file and transcribe/convert it to text file
|
// Check if the file is an audio file and transcribe/convert it to text file
|
||||||
if (['audio/mpeg', 'audio/wav'].includes(file['type'])) {
|
if (['audio/mpeg', 'audio/wav'].includes(file['type'])) {
|
||||||
@ -118,11 +116,11 @@
|
|||||||
const fileItem = {
|
const fileItem = {
|
||||||
type: 'file',
|
type: 'file',
|
||||||
file: '',
|
file: '',
|
||||||
id: fileId,
|
id: null,
|
||||||
url: '',
|
url: '',
|
||||||
name: file.name,
|
name: file.name,
|
||||||
collection_name: '',
|
collection_name: '',
|
||||||
status: 'uploaded',
|
status: '',
|
||||||
size: file.size,
|
size: file.size,
|
||||||
error: ''
|
error: ''
|
||||||
};
|
};
|
||||||
@ -132,6 +130,7 @@
|
|||||||
const uploadedFile = await uploadFile(localStorage.token, file);
|
const uploadedFile = await uploadFile(localStorage.token, file);
|
||||||
|
|
||||||
if (uploadedFile) {
|
if (uploadedFile) {
|
||||||
|
fileItem.status = 'uploaded';
|
||||||
fileItem.file = uploadedFile;
|
fileItem.file = uploadedFile;
|
||||||
fileItem.id = uploadedFile.id;
|
fileItem.id = uploadedFile.id;
|
||||||
fileItem.url = `${WEBUI_API_BASE_URL}/files/${uploadedFile.id}`;
|
fileItem.url = `${WEBUI_API_BASE_URL}/files/${uploadedFile.id}`;
|
||||||
@ -152,11 +151,11 @@
|
|||||||
processFileItem(fileItem);
|
processFileItem(fileItem);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
files = files.filter((item) => item.id !== fileId);
|
files = files.filter((item) => item.status !== null);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (e) {
|
||||||
toast.error(error);
|
toast.error(e);
|
||||||
files = files.filter((item) => item.id !== fileId);
|
files = files.filter((item) => item.status !== null);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -173,7 +172,6 @@
|
|||||||
// Remove the failed doc from the files array
|
// Remove the failed doc from the files array
|
||||||
// files = files.filter((f) => f.id !== fileItem.id);
|
// files = files.filter((f) => f.id !== fileItem.id);
|
||||||
toast.error(e);
|
toast.error(e);
|
||||||
|
|
||||||
fileItem.status = 'processed';
|
fileItem.status = 'processed';
|
||||||
files = files;
|
files = files;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user