mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-10-01 15:48:23 -05:00
Remove avatar loading state to avoid flicker
Original reason why it's there (by hfcRed): If you render someones icon, it exports it as an image and puts in the cache, so when you navigate and that same person appears again on the next page, it pulls the rendered image from the cache and uses that instead of a canvas But could not reproduce any kind of "pop in".
This commit is contained in:
@@ -1,12 +1,3 @@
|
||||
.identicon {
|
||||
filter: blur(99px);
|
||||
transition: filter 0.3s;
|
||||
}
|
||||
|
||||
.loaded {
|
||||
filter: blur(0);
|
||||
}
|
||||
|
||||
.avatarWrapper {
|
||||
flex-shrink: 0;
|
||||
width: fit-content;
|
||||
|
||||
@@ -120,14 +120,8 @@ export function Avatar({
|
||||
size: keyof typeof dimensions;
|
||||
} & React.ButtonHTMLAttributes<HTMLImageElement>) {
|
||||
const [isErrored, setIsErrored] = React.useState(false);
|
||||
const [loaded, setLoaded] = React.useState(false);
|
||||
const isClient = useHydrated();
|
||||
|
||||
const isIdenticon =
|
||||
!url &&
|
||||
(!user?.customAvatarUrl || isErrored) &&
|
||||
(!user?.discordAvatar || isErrored || identiconInput);
|
||||
|
||||
const identiconSource = identiconInput ?? user?.discordId ?? "unknown";
|
||||
|
||||
const src = url
|
||||
@@ -147,17 +141,12 @@ export function Avatar({
|
||||
return (
|
||||
<div className={clsx(styles.avatarWrapper, className)}>
|
||||
<img
|
||||
className={clsx({
|
||||
[styles.identicon]: isIdenticon,
|
||||
[styles.loaded]: loaded,
|
||||
})}
|
||||
src={src}
|
||||
alt={alt}
|
||||
title={alt ? alt : undefined}
|
||||
width={dimensions[size]}
|
||||
height={dimensions[size]}
|
||||
onError={() => setIsErrored(true)}
|
||||
onLoad={() => setLoaded(true)}
|
||||
{...rest}
|
||||
/>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user