From 1f5390328855ae3a0bdc9dda029a66c6de055e08 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Thu, 12 Dec 2019 15:30:50 +0300 Subject: Fix external avatar loading flow --- vnext/src/ui/Thread.js | 30 ++++++++++++++---------------- vnext/src/ui/UserInfo.js | 10 ++++++++-- vnext/src/ui/assets/av-96.png | Bin 0 -> 2018 bytes 3 files changed, 22 insertions(+), 18 deletions(-) create mode 100644 vnext/src/ui/assets/av-96.png (limited to 'vnext/src') diff --git a/vnext/src/ui/Thread.js b/vnext/src/ui/Thread.js index ec8a1eda..9d22200c 100644 --- a/vnext/src/ui/Thread.js +++ b/vnext/src/ui/Thread.js @@ -45,22 +45,20 @@ function Comment({ msg, draft, visitor, active, setActive, onStartEditing, postC } } }, []); - useEffect(() => { - isMounted = true; - setAuthor(previous => { - if (previous.uri) { - fetchUserUri(previous.uri).then(response => { - if (isMounted) { - return response.data; - } - }); - } - return previous; - }); - return () => { - isMounted = false; - }; - }, []); + const userRef = useRef(author); + useEffect(() => { + isMounted = true; + if (userRef.current.uri) { + fetchUserUri(userRef.current.uri).then(response => { + if (isMounted) { + setAuthor(response.data); + } + }); + } + return () => { + isMounted = false; + }; + }, [msg.user]); return (