diff --git a/frontend/src/api/pub.ts b/frontend/src/api/pub.ts index 74aeedf0..4304c47a 100644 --- a/frontend/src/api/pub.ts +++ b/frontend/src/api/pub.ts @@ -12,7 +12,7 @@ export async function fetch(url: string, password: string = "") { false ); - const data = await res.json(); + const data = (await res.json()) as Resource; console.log(data); data.url = `/share${url}`; @@ -33,12 +33,11 @@ export async function fetch(url: string, password: string = "") { return data; } -// Is this redundant code? export function download( - format: any, + format: DownloadFormat, hash: string, token: string, - ...files: any + ...files: string[] ) { let url = `${baseURL}/api/public/dl/${hash}`; diff --git a/frontend/src/types/file.d.ts b/frontend/src/types/file.d.ts index 557f2260..fd950460 100644 --- a/frontend/src/types/file.d.ts +++ b/frontend/src/types/file.d.ts @@ -34,3 +34,13 @@ type ResourceType = | "text" | "blob" | "textImmutable"; + +type DownloadFormat = + | "zip" + | "tar" + | "targz" + | "tarbz2" + | "tarxz" + | "tarlz4" + | "tarsz" + | null; diff --git a/frontend/src/views/Share.vue b/frontend/src/views/Share.vue index da253f23..65d56ef0 100644 --- a/frontend/src/views/Share.vue +++ b/frontend/src/views/Share.vue @@ -203,8 +203,8 @@ const error = ref(null); const showLimit = ref(100); const password = ref(""); const attemptedPasswordLogin = ref(false); -const hash = ref(null); -const token = ref(null); +const hash = ref(""); +const token = ref(""); const clip = ref(null); const $showSuccess = inject("$showError")!; @@ -308,18 +308,21 @@ const isSingleFile = () => !req.value?.items[fileStore.selected[0]].isDir; const download = () => { + if (!req.value) return false; + if (isSingleFile()) { api.download( null, hash.value, token.value, - req.value?.items[fileStore.selected[0]].path + req.value.items[fileStore.selected[0]].path ); - return; + return true; } + layoutStore.showHover({ prompt: "download", - confirm: (format: any) => { + confirm: (format: DownloadFormat) => { if (req.value === null) return false; layoutStore.closeHovers(); @@ -330,8 +333,11 @@ const download = () => { } api.download(format, hash.value, token.value, ...files); + return true; }, }); + + return true; }; const linkSelected = () => { diff --git a/frontend/src/views/settings/Global.vue b/frontend/src/views/settings/Global.vue index 2ec20e6d..b2a9e07a 100644 --- a/frontend/src/views/settings/Global.vue +++ b/frontend/src/views/settings/Global.vue @@ -329,6 +329,8 @@ const save = async () => { } catch (e: any) { $showError(e); } + + return true; }; // Parse the user-friendly input (e.g., "20M" or "1T") to bytes const parseBytes = (input: string) => { diff --git a/frontend/src/views/settings/Profile.vue b/frontend/src/views/settings/Profile.vue index 1e6285cc..2c4023fe 100644 --- a/frontend/src/views/settings/Profile.vue +++ b/frontend/src/views/settings/Profile.vue @@ -120,6 +120,7 @@ onMounted(() => { singleClick.value = authStore.user.singleClick; dateFormat.value = authStore.user.dateFormat; layoutStore.loading = false; + return true; }); const updatePassword = async (event: Event) => { diff --git a/frontend/src/views/settings/User.vue b/frontend/src/views/settings/User.vue index e0e83707..e2463a18 100644 --- a/frontend/src/views/settings/User.vue +++ b/frontend/src/views/settings/User.vue @@ -154,6 +154,8 @@ const deleteUser = async (e: Event) => { $showError(err); } } + + return true; }; const save = async (event: Event) => { event.preventDefault(); @@ -183,5 +185,7 @@ const save = async (event: Event) => { } catch (e: any) { $showError(e); } + + return true; }; diff --git a/frontend/tsconfig.json b/frontend/tsconfig.json index 4b83bbfa..9cd2b562 100644 --- a/frontend/tsconfig.json +++ b/frontend/tsconfig.json @@ -8,6 +8,7 @@ "moduleResolution": "Node10", "strict": true, "sourceMap": true, + "noImplicitReturns": true, "resolveJsonModule": true, "isolatedModules": true, "esModuleInterop": true,