Handle the case of no avatar (#2959)

* Handle the case of no avatar

* ci go

* Scope to the top if...

* Account for CI's usage of dev API key causing avatar to show
This commit is contained in:
49fl
2024-07-10 13:13:33 -04:00
committed by GitHub
parent 3160c58d8a
commit 263a4f324d
3 changed files with 56 additions and 2 deletions

View File

@ -126,11 +126,17 @@ async function getUser(context: UserContext) {
if (!token && isTauri()) return Promise.reject(new Error('No token found'))
if (token) headers['Authorization'] = `Bearer ${context.token}`
if (SKIP_AUTH)
if (SKIP_AUTH) {
// For local tests
if (localStorage.getItem('FORCE_NO_IMAGE')) {
LOCAL_USER.image = ''
}
return {
user: LOCAL_USER,
token,
}
}
const userPromise = !isTauri()
? fetch(url, {
@ -144,6 +150,11 @@ async function getUser(context: UserContext) {
const user = await userPromise
// Necessary here because we use Kurt's API key in CI
if (localStorage.getItem('FORCE_NO_IMAGE')) {
user.image = ''
}
if ('error_code' in user) return Promise.reject(new Error(user.message))
return {