Increased upload message duration

This commit is contained in:
Eduard Urbach 2018-03-03 19:58:18 +01:00
parent a1c3fc5468
commit 05b2e041cf

View File

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