diff --git a/packages/frontend/src/components/MkUploaderDialog.vue b/packages/frontend/src/components/MkUploaderDialog.vue index eae0470f96..a1119b947f 100644 --- a/packages/frontend/src/components/MkUploaderDialog.vue +++ b/packages/frontend/src/components/MkUploaderDialog.vue @@ -22,7 +22,7 @@ SPDX-License-Identifier: AGPL-3.0-only :key="ctx.id" v-panel :class="[$style.item, ctx.waiting ? $style.itemWaiting : null, ctx.uploaded ? $style.itemCompleted : null, ctx.uploadFailed ? $style.itemFailed : null]" - :style="{ '--p': ctx.progressValue !== null ? `${ctx.progressValue / ctx.progressMax * 100}%` : '0%' }" + :style="{ '--p': ctx.progress != null ? `${ctx.progress.value / ctx.progress.max * 100}%` : '0%' }" >
@@ -127,8 +127,7 @@ const emit = defineEmits<{ const items = ref([] as { id: string; name: string; - progressMax: number | null; - progressValue: number | null; + progress: { max: number; value: number } | null; thumbnail: string; waiting: boolean; uploading: boolean; @@ -263,13 +262,16 @@ async function upload() { // エラーハンドリングなどを考慮してシ folderId: props.folderId, onProgress: (progress) => { item.waiting = false; - item.progressMax = progress.total; - item.progressValue = progress.loaded; + if (item.progress == null) { + item.progress = { max: progress.total, value: progress.loaded }; + } else { + item.progress.value = progress.loaded; + item.progress.max = progress.total; + } }, }).catch(err => { item.uploadFailed = true; - item.progressMax = null; - item.progressValue = null; + item.progress = null; throw err; }).finally(() => { item.uploading = false; @@ -287,8 +289,7 @@ onMounted(() => { items.value.push({ id, name: prefer.s.keepOriginalFilename ? filename : id + extension, - progressMax: null, - progressValue: null, + progress: null, thumbnail: window.URL.createObjectURL(file), waiting: false, uploading: false, diff --git a/packages/frontend/src/utility/select-file.ts b/packages/frontend/src/utility/select-file.ts index b4d9efa3d5..00145169ad 100644 --- a/packages/frontend/src/utility/select-file.ts +++ b/packages/frontend/src/utility/select-file.ts @@ -48,6 +48,7 @@ export function chooseFileFromUrl(): Promise { const marker = Math.random().toString(); // TODO: UUIDとか使う + // TODO: no websocketモード対応 const connection = useStream().useChannel('main'); connection.on('urlUploadFinished', urlResponse => { if (urlResponse.marker === marker) {