diff --git a/frontend/src/api/files.ts b/frontend/src/api/files.ts index b0aec161..5c7e1e61 100644 --- a/frontend/src/api/files.ts +++ b/frontend/src/api/files.ts @@ -178,7 +178,7 @@ export function copy(items: any[], overwrite = false, rename = false) { return moveCopy(items, true, overwrite, rename); } -export async function checksum(url: string, algo: ChecksumAlgs) { +export async function checksum(url: string, algo: ChecksumAlg) { const data = await resourceAction(`${url}?checksum=${algo}`, "GET"); return (await data.json()).checksums[algo]; } diff --git a/frontend/src/stores/clipboard.ts b/frontend/src/stores/clipboard.ts index 23eb54b2..5ad8a775 100644 --- a/frontend/src/stores/clipboard.ts +++ b/frontend/src/stores/clipboard.ts @@ -2,7 +2,11 @@ import { defineStore } from "pinia"; export const useClipboardStore = defineStore("clipboard", { // convert to a function - state: () => ({ + state: (): { + key: string; + items: ClipItem[]; + path?: string; + } => ({ key: "", items: [], path: undefined, @@ -12,11 +16,6 @@ export const useClipboardStore = defineStore("clipboard", { }, actions: { // no context as first argument, use `this` instead - updateClipboard(value: any) { - this.key = value.key; - this.items = value.items; - this.path = value.path; - }, // easily reset state using `$reset` resetClipboard() { this.$reset(); diff --git a/frontend/src/stores/file.ts b/frontend/src/stores/file.ts index 9065daed..ca6721eb 100644 --- a/frontend/src/stores/file.ts +++ b/frontend/src/stores/file.ts @@ -6,7 +6,7 @@ export const useFileStore = defineStore("file", { req: Resource | null; oldReq: Resource | null; reload: boolean; - selected: any[]; + selected: number[]; multiple: boolean; isFiles: boolean; } => ({ diff --git a/frontend/src/stores/router.ts b/frontend/src/stores/router.ts index 99d10db6..e598824c 100644 --- a/frontend/src/stores/router.ts +++ b/frontend/src/stores/router.ts @@ -1,6 +1,7 @@ import { defineStore } from "pinia"; /** + * Dummy store for exposing router to be used in other stores * @example * // route: () => { * // const routerStore = useRouterStore(); diff --git a/frontend/src/types/api.d.ts b/frontend/src/types/api.d.ts index 6412ae0d..66685e5e 100644 --- a/frontend/src/types/api.d.ts +++ b/frontend/src/types/api.d.ts @@ -17,9 +17,7 @@ interface TusSettings { chunkSize: number; } -type ChecksumAlgs = "md5" | "sha1" | "sha256" | "sha512"; - -type inline = any; +type ChecksumAlg = "md5" | "sha1" | "sha256" | "sha512"; interface Share { hash: string; diff --git a/frontend/src/types/file.d.ts b/frontend/src/types/file.d.ts index 6e7868d9..69eac10e 100644 --- a/frontend/src/types/file.d.ts +++ b/frontend/src/types/file.d.ts @@ -43,3 +43,8 @@ type DownloadFormat = | "tarlz4" | "tarsz" | null; + +interface ClipItem { + from: string; + name: string; +} diff --git a/frontend/src/types/utils.d.ts b/frontend/src/types/utils.d.ts deleted file mode 100644 index 4c77acc1..00000000 --- a/frontend/src/types/utils.d.ts +++ /dev/null @@ -1 +0,0 @@ -type settings = any; diff --git a/frontend/src/utils/auth.ts b/frontend/src/utils/auth.ts index 520f4f63..538c8ee1 100644 --- a/frontend/src/utils/auth.ts +++ b/frontend/src/utils/auth.ts @@ -1,12 +1,12 @@ import { useAuthStore } from "@/stores/auth"; import router from "@/router"; -import jwt_decode from "jwt-decode"; +import jwt_decode, { JwtPayload } from "jwt-decode"; import { baseURL } from "./constants"; import { StatusError } from "@/api/utils"; export function parseToken(token: string) { // falsy or malformed jwt will throw InvalidTokenError - const data = jwt_decode<{ [key: string]: any; user: IUser }>(token); + const data = jwt_decode(token); document.cookie = `auth=${token}; Path=/; SameSite=Strict;`; @@ -48,7 +48,7 @@ export async function login( if (res.status === 200) { parseToken(body); } else { - throw new Error(body); + throw new StatusError(body, res.status); } } @@ -65,7 +65,7 @@ export async function renew(jwt: string) { if (res.status === 200) { parseToken(body); } else { - throw new Error(body); + throw new StatusError(body, res.status); } } diff --git a/frontend/src/utils/css.ts b/frontend/src/utils/css.ts index 08855b8c..d727786b 100644 --- a/frontend/src/utils/css.ts +++ b/frontend/src/utils/css.ts @@ -1,4 +1,4 @@ -export default function getRule(rules: any) { +export default function getRule(rules: string[]) { for (let i = 0; i < rules.length; i++) { rules[i] = rules[i].toLowerCase(); } diff --git a/frontend/src/views/files/FileListing.vue b/frontend/src/views/files/FileListing.vue index da520a14..faed1928 100644 --- a/frontend/src/views/files/FileListing.vue +++ b/frontend/src/views/files/FileListing.vue @@ -535,9 +535,9 @@ export default { return; } - this.clipboardStore.updateClipboard({ - key: key, - items: items, + this.clipboardStore.$patch({ + key, + items, path: this.$route.path, }); },