From 3849d6b44704bb0fcffe15816b01422570f9c41a Mon Sep 17 00:00:00 2001 From: Michael Peters Date: Sat, 12 Feb 2022 17:55:11 -0600 Subject: [PATCH] fix member flicker (use recoil-cached image src) --- .../elements/lists/components/message-element.tsx | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/client/webapp/elements/lists/components/message-element.tsx b/src/client/webapp/elements/lists/components/message-element.tsx index 5eb86c9..9429d95 100644 --- a/src/client/webapp/elements/lists/components/message-element.tsx +++ b/src/client/webapp/elements/lists/components/message-element.tsx @@ -111,14 +111,11 @@ const MessageElement: FC = (props: MessageElementProps) => [message, prevMessage], ); - const [avatarSrc] = useOneTimeAsyncAction( - async () => { - if (message.isContinued(prevMessage)) return './img/loading.svg'; // don't load for elements that won't use it - if (!(message.member instanceof Member)) return './img/error.png'; // TODO: Make this a nicer 'unknown' image - return await ElementsUtil.getImageSrcFromResourceFailSoftly(guild, message.member.avatarResourceId); - }, - './img/loading.svg', - [message], + const avatarSrc = useRecoilValueSoftImgSrc( + guildResourceSoftImgSrcState({ + guildId: guild.id, + resourceId: message.member instanceof Member ? message.member.avatarResourceId : null, + }), ); const dateSpacer = useMemo(() => {