Add avatar cache busting using random query param
This commit is contained in:
parent
7043b4f1d1
commit
31fa3dcf26
@ -71,14 +71,22 @@ function HeaderPhoto ({ user, isMe }) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
onCompleted ({ setPhoto: photoId }) {
|
||||||
|
// add random query param for cache busting
|
||||||
|
const randomParam = (Math.random() + 1).toString(16).substring(2)
|
||||||
|
const src = `https://${process.env.NEXT_PUBLIC_AWS_UPLOAD_BUCKET}.s3.amazonaws.com/${user.photoId}?r=${randomParam}`
|
||||||
|
setSrc(src)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
const initialSrc = user.photoId ? `https://${process.env.NEXT_PUBLIC_AWS_UPLOAD_BUCKET}.s3.amazonaws.com/${user.photoId}` : '/dorian400.jpg'
|
||||||
|
const [src, setSrc] = useState(initialSrc)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='position-relative align-self-start' style={{ width: 'fit-content' }}>
|
<div className='position-relative align-self-start' style={{ width: 'fit-content' }}>
|
||||||
<Image
|
<Image
|
||||||
src={user.photoId ? `https://${process.env.NEXT_PUBLIC_AWS_UPLOAD_BUCKET}.s3.amazonaws.com/${user.photoId}` : '/dorian400.jpg'} width='135' height='135'
|
src={src} width='135' height='135'
|
||||||
className={styles.userimg}
|
className={styles.userimg}
|
||||||
/>
|
/>
|
||||||
{isMe &&
|
{isMe &&
|
||||||
|
Loading…
x
Reference in New Issue
Block a user