From ea8b32df2e358f891ff57a1a1bd4b515c399c500 Mon Sep 17 00:00:00 2001 From: Immanuel Onyeka Date: Sun, 17 Dec 2023 14:02:41 -0500 Subject: [PATCH] Correct letterhead rendering when avatar is missing --- components/app.vue | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/components/app.vue b/components/app.vue index 4c227ff..dac5157 100644 --- a/components/app.vue +++ b/components/app.vue @@ -110,20 +110,25 @@ function getUser() { return getAvatar(token) }).then(b => { - if (!b) return // Exit if token is invalid const validTypes = ['image/jpeg', 'image/png'] if (!b || !validTypes.includes(b.type) || b.size <= 1) { - return fetch("/assets/image/default-avatar.jpg"). + fetch("/assets/image/default-avatar.jpg"). then(r => r.blob()).then( a => this.user.avatar = a ) + } else { + this.user.avatar = b } - this.user.avatar = b return getLetterhead(token) }).then(b => { - if (!b) return // Exit if token is invalid - const validTypes = ['image/jpeg', 'image/png'] - this.user.letterhead = b + const validTypes = ['image/jpeg', 'image/png'] + + if (!b || !validTypes.includes(b.type) || b.size <= 1) { + fetch("/assets/image/default-avatar.jpg"). + then(r => r.blob()).then( a => this.user.letterhead = a ) + } else { + this.user.letterhead = b + } }) }