diff options
author | Vitaly Takmazov | 2019-12-12 15:30:50 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2023-01-13 10:37:55 +0300 |
commit | 1f5390328855ae3a0bdc9dda029a66c6de055e08 (patch) | |
tree | 5560035c3591b07f98dbdd6fb045c92b6c9666b2 /vnext/src/ui/Thread.js | |
parent | 526f5d3a2fc6a9bf5d20f8a34ca77acb4a3a9887 (diff) |
Fix external avatar loading flow
Diffstat (limited to 'vnext/src/ui/Thread.js')
-rw-r--r-- | vnext/src/ui/Thread.js | 30 |
1 files changed, 14 insertions, 16 deletions
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 ( <div style={chatItemStyle(visitor, msg)}> <div className="msg-header"> |