Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix avatar caching for non-user rendering #1491

Merged
merged 1 commit into from
Oct 20, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/components/Avatar/Avatar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ function getUserHasAvatar(userId) {
}
function setUserHasAvatar(userId, flag) {
browserStorage.setItem('user-has-avatar.' + userId, flag)
if (userId) {
browserStorage.setItem('user-has-avatar.' + userId, flag)
}
}
export default {
Expand Down Expand Up @@ -516,7 +518,7 @@ export default {
updateImageIfValid(url, srcset = null) {
// skip loading
const userHasAvatar = getUserHasAvatar(this.user)
if (typeof userHasAvatar === 'boolean') {
if (this.isUserDefined && typeof userHasAvatar === 'boolean') {
this.isAvatarLoaded = true
this.avatarUrlLoaded = url
if (srcset) {
Expand All @@ -539,8 +541,13 @@ export default {
setUserHasAvatar(this.user, true)
}
img.onerror = () => {
console.debug('Invalid avatar url', url)
// Avatar is invalid, reset
this.avatarUrlLoaded = null
this.avatarSrcSetLoaded = null
this.userDoesNotExist = true
this.isAvatarLoaded = true
this.isAvatarLoaded = false
setUserHasAvatar(this.user, false)
}
Expand Down