From c2b9ef6c2f33b3f4f98845a8c6374dda12c1c8e4 Mon Sep 17 00:00:00 2001 From: Leo Vasanko Date: Sun, 12 Nov 2023 22:58:56 +0000 Subject: [PATCH] Frontend typing fixes, removing dead code. --- frontend/src/components/FileViewer.vue | 52 ------------------- frontend/src/components/HeaderMain.vue | 12 ++--- frontend/src/components/HeaderSelected.vue | 2 +- .../src/components/NotificationLoading.vue | 27 ---------- frontend/src/components/UploadButton.vue | 7 +-- frontend/src/repositories/WS.ts | 2 +- frontend/src/stores/documents.ts | 5 +- 7 files changed, 13 insertions(+), 94 deletions(-) delete mode 100644 frontend/src/components/FileViewer.vue delete mode 100644 frontend/src/components/NotificationLoading.vue diff --git a/frontend/src/components/FileViewer.vue b/frontend/src/components/FileViewer.vue deleted file mode 100644 index 4e45e02..0000000 --- a/frontend/src/components/FileViewer.vue +++ /dev/null @@ -1,52 +0,0 @@ - - - - - diff --git a/frontend/src/components/HeaderMain.vue b/frontend/src/components/HeaderMain.vue index 58c6e53..f8206c1 100644 --- a/frontend/src/components/HeaderMain.vue +++ b/frontend/src/components/HeaderMain.vue @@ -9,7 +9,7 @@
@@ -42,15 +42,15 @@ const showSearchInput = ref(false) const search = ref() const searchButton = ref() -const closeSearch = ev => { +const closeSearch = (ev: Event) => { if (!showSearchInput.value) return // Already closing showSearchInput.value = false const breadcrumb = document.querySelector('.breadcrumb') as HTMLElement breadcrumb.focus() updateSearch(ev) } -const updateSearch = ev => { - const q = ev.target.value +const updateSearch = (ev: Event) => { + const q = (ev.target as HTMLInputElement).value let p = props.path.join('/') p = p ? `/${p}` : '' const url = q ? `${p}//${q}` : (p || '/') @@ -58,9 +58,9 @@ const updateSearch = ev => { if (!props.query && q) router.push(url) else router.replace(url) } -const toggleSearchInput = () => { +const toggleSearchInput = (ev: Event) => { showSearchInput.value = !showSearchInput.value - if (!showSearchInput.value) return closeSearch() + if (!showSearchInput.value) return closeSearch(ev) nextTick(() => { const input = search.value if (input) input.focus() diff --git a/frontend/src/components/HeaderSelected.vue b/frontend/src/components/HeaderSelected.vue index cdfd0d7..3cf27a1 100644 --- a/frontend/src/components/HeaderSelected.vue +++ b/frontend/src/components/HeaderSelected.vue @@ -34,7 +34,7 @@ const op = (op: string, dst?: string) => { // @ts-ignore if (dst !== undefined) msg.dst = dst const control = connect(controlUrl, { - message(ev: WebSocmetMessageEvent) { + message(ev: MessageEvent) { const res = JSON.parse(ev.data) if ('error' in res) { console.error('Control socket error', msg, res.error) diff --git a/frontend/src/components/NotificationLoading.vue b/frontend/src/components/NotificationLoading.vue deleted file mode 100644 index 81e9cde..0000000 --- a/frontend/src/components/NotificationLoading.vue +++ /dev/null @@ -1,27 +0,0 @@ - - - - diff --git a/frontend/src/components/UploadButton.vue b/frontend/src/components/UploadButton.vue index b2b69d9..91d7521 100644 --- a/frontend/src/components/UploadButton.vue +++ b/frontend/src/components/UploadButton.vue @@ -32,7 +32,7 @@ function uploadHandler(event: Event) { if (!infiles.length) return infiles.sort((a, b) => collator.compare(a.cloudName, b.cloudName)) // @ts-ignore - upqueue = upqueue.concat(infiles) + upqueue = [...upqueue, ...infiles] statsAdd(infiles) startWorker() } @@ -49,13 +49,14 @@ const uprogress_init = { tlast: 0, statbytes: 0, statdur: 0, - files: [], + files: [] as File[], filestart: 0, fileidx: 0, filecount: 0, filename: '', filesize: 0, filepos: 0, + status: 'idle', } const uprogress = reactive({...uprogress_init}) const percent = computed(() => uprogress.uploaded / uprogress.total * 100) @@ -109,7 +110,7 @@ const statsAdd = (f: Array) => { if (uprogress.files.length === 0) statReset() uprogress.total += f.reduce((a, b) => a + b.size, 0) uprogress.filecount += f.length - uprogress.files = uprogress.files.concat(f) + uprogress.files = [...uprogress.files, ...f] statNextFile() } let upqueue = [] as File[] diff --git a/frontend/src/repositories/WS.ts b/frontend/src/repositories/WS.ts index a2476ce..0e582dc 100644 --- a/frontend/src/repositories/WS.ts +++ b/frontend/src/repositories/WS.ts @@ -109,7 +109,7 @@ const handleWatchMessage = (event: MessageEvent) => { } } -function handleRootMessage({ root }: { root: DirEntry }) { +function handleRootMessage({ root }: { root: FileEntry[] }) { const store = useDocumentStore() console.log('Watch root', root) store.updateRoot(root) diff --git a/frontend/src/stores/documents.ts b/frontend/src/stores/documents.ts index 6004d19..a99cbfb 100644 --- a/frontend/src/stores/documents.ts +++ b/frontend/src/stores/documents.ts @@ -21,9 +21,7 @@ export const useDocumentStore = defineStore({ state: () => ({ document: [] as Document[], selected: new Set(), - uploadingDocuments: [], - uploadCount: 0 as number, - fileExplorer: null, + fileExplorer: null as any, error: '' as string, connected: false, server: {} as Record, @@ -53,7 +51,6 @@ export const useDocumentStore = defineStore({ }) loc.push(name) } - console.log("Documents", docs) this.document = docs as Document[] }, updateModified() {