Skip to content

Commit

Permalink
Merge pull request #1491 from nextcloud/fix/avatar-caching
Browse files Browse the repository at this point in the history
Fix avatar caching for non-user rendering
  • Loading branch information
PVince81 authored Oct 20, 2020
2 parents f6812c3 + 18f06e9 commit 8e4e1f2
Showing 1 changed file with 10 additions and 3 deletions.
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

0 comments on commit 8e4e1f2

Please sign in to comment.