From 8aecfadb13f8fc6053470d80de2acd2b3f160f57 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 28 Oct 2022 13:43:49 +0300 Subject: Fix remote user fetching --- vnext/src/ui/Thread.js | 55 ++++++++++++++++++++++++++---------------------- vnext/src/ui/UserInfo.js | 9 ++++++-- 2 files changed, 37 insertions(+), 27 deletions(-) (limited to 'vnext/src/ui') diff --git a/vnext/src/ui/Thread.js b/vnext/src/ui/Thread.js index 92638104..a290acd7 100644 --- a/vnext/src/ui/Thread.js +++ b/vnext/src/ui/Thread.js @@ -46,19 +46,24 @@ function Comment({ msg, draft, visitor, active, setActive, onStartEditing, postC } }, []); const userRef = useRef(author); - useEffect(() => { - isMounted = true; - if (userRef.current.uri) { - fetchUserUri(userRef.current.uri).then(response => { - if (isMounted) { - setAuthor(response.data); - } - }); + useEffect(() => { + isMounted = true; + if (userRef.current.uri) { + fetchUserUri(userRef.current.uri).then(remote_user => { + if (isMounted) { + setAuthor({ + uid: 0, + uname: remote_user.data.preferredUsername, + avatar: remote_user.data.icon && remote_user.data.icon.url, + uri: author.uri + }); } - return () => { - isMounted = false; - }; - }, [msg.user]); + }); + } + return () => { + isMounted = false; + }; + }, [author.uri, msg.user]); return (