diff --git a/scripts/Actions/Upload.ts b/scripts/Actions/Upload.ts index e176271f..08937e96 100644 --- a/scripts/Actions/Upload.ts +++ b/scripts/Actions/Upload.ts @@ -1,4 +1,5 @@ import { AnimeNotifier } from "../AnimeNotifier" +import { StatusMessage } from "../StatusMessage" // Select file export function selectFile(arn: AnimeNotifier, button: HTMLButtonElement) { @@ -13,6 +14,11 @@ export function selectFile(arn: AnimeNotifier, button: HTMLButtonElement) { return } + if(!file.type.startsWith("image/")) { + arn.statusMessage.showError(file.name + " is not an image file!") + return + } + previewImage(file, preview) uploadFile(file, "/api/upload/avatar", arn) } @@ -43,7 +49,7 @@ function uploadFile(file: File, endpoint: string, arn: AnimeNotifier) { let reader = new FileReader() reader.onloadend = async () => { - arn.statusMessage.showInfo("Uploading avatar...") + arn.statusMessage.showInfo("Uploading avatar...", 60000) let response = await fetch(endpoint, { method: "POST",