dont use [...path] routing since it breaks building statically
This commit is contained in:
@@ -16,9 +16,16 @@ import { uploadToWarren } from '~/lib/api/warrens';
|
||||
import { toast } from 'vue-sonner';
|
||||
import UploadListEntry from './UploadListEntry.vue';
|
||||
|
||||
const warrenStore = useWarrenStore();
|
||||
const uploadStore = useUploadStore();
|
||||
|
||||
const warrenRoute = useWarrenRoute();
|
||||
const currentAndUploadRouteMatch = computed(
|
||||
() =>
|
||||
uploadStore.destination != null &&
|
||||
warrenStore.current != null &&
|
||||
uploadStore.destination.warrenId == warrenStore.current.warrenId &&
|
||||
uploadStore.destination.path == warrenStore.current.path
|
||||
);
|
||||
|
||||
const fileInputElement = ref<HTMLInputElement>(
|
||||
null as unknown as HTMLInputElement
|
||||
@@ -28,7 +35,7 @@ const uploading = ref(false);
|
||||
const presentPaths = new Set<string>();
|
||||
|
||||
function onFilesChanged(event: Event) {
|
||||
if (warrenRoute.value == null) {
|
||||
if (warrenStore.current == null) {
|
||||
toast.warning('Upload', {
|
||||
description: 'Enter a warren before attempting to upload files',
|
||||
});
|
||||
@@ -45,9 +52,9 @@ function onFilesChanged(event: Event) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (uploadStore.path == null) {
|
||||
uploadStore.path = warrenRoute.value;
|
||||
} else if (uploadStore.path !== warrenRoute.value) {
|
||||
if (uploadStore.destination == null) {
|
||||
uploadStore.destination = warrenStore.current;
|
||||
} else if (currentAndUploadRouteMatch.value) {
|
||||
toast.warning('Upload', {
|
||||
description:
|
||||
'The unfinished items belong to a different directory. Remove them before attempting to upload to a different directory.',
|
||||
@@ -78,7 +85,7 @@ function removeFile(index: number) {
|
||||
presentPaths.delete(file.data.name);
|
||||
|
||||
if (uploadStore.files.length < 1) {
|
||||
uploadStore.path = null;
|
||||
uploadStore.destination = null;
|
||||
uploadStore.progress = null;
|
||||
}
|
||||
}
|
||||
@@ -94,7 +101,7 @@ function clearCompletedFiles() {
|
||||
});
|
||||
|
||||
if (uploadStore.files.length < 1) {
|
||||
uploadStore.path = null;
|
||||
uploadStore.destination = null;
|
||||
uploadStore.progress = null;
|
||||
}
|
||||
}
|
||||
@@ -126,7 +133,7 @@ function updateFileListStatus(loadedBytes: number, ended: boolean = false) {
|
||||
}
|
||||
|
||||
async function submit() {
|
||||
if (uploadStore.path == null) {
|
||||
if (uploadStore.destination == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -154,7 +161,8 @@ async function submit() {
|
||||
};
|
||||
|
||||
const { success } = await uploadToWarren(
|
||||
uploadStore.path,
|
||||
uploadStore.destination.warrenId,
|
||||
uploadStore.destination.path,
|
||||
dt.files,
|
||||
(loaded, total) => {
|
||||
if (uploadStore.progress != null) {
|
||||
@@ -192,10 +200,13 @@ async function submit() {
|
||||
<DialogDescription
|
||||
>Upload files to
|
||||
<span class="text-foreground">{{
|
||||
uploadStore.path == null ||
|
||||
warrenRoute === uploadStore.path
|
||||
currentAndUploadRouteMatch ||
|
||||
uploadStore.destination == null
|
||||
? 'the current directory'
|
||||
: routeWithWarrenName(uploadStore.path)
|
||||
: routeWithWarrenName(
|
||||
uploadStore.destination!.warrenId,
|
||||
uploadStore.destination!.path
|
||||
)
|
||||
}}</span></DialogDescription
|
||||
>
|
||||
</DialogHeader>
|
||||
|
||||
Reference in New Issue
Block a user