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') 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 (
@@ -105,10 +110,10 @@ function Comment({ msg, draft, visitor, active, setActive, onStartEditing, postC } ) : ( - <> -  · {active === msg.rid || } - - ) + <> +  · {active === msg.rid || } + + ) }
@@ -204,8 +209,8 @@ export default function Thread(props) { {active === (message.rid || 0) && Write a comment...} ) : ( - - ) + + ) } { message.replies && } diff --git a/vnext/src/ui/UserInfo.js b/vnext/src/ui/UserInfo.js index 5fe244ea..9a663829 100644 --- a/vnext/src/ui/UserInfo.js +++ b/vnext/src/ui/UserInfo.js @@ -100,9 +100,14 @@ export function UserLink(props) { useEffect(() => { isMounted = true; if (userRef.current.uri) { - fetchUserUri(userRef.current.uri).then(response => { + fetchUserUri(userRef.current.uri).then(remote_user => { if (isMounted) { - setUser(response.data); + setUser({ + uid: 0, + uname: remote_user.data.preferredUsername, + avatar: remote_user.data.icon && remote_user.data.icon.url, + uri: userRef.current.uri + }); } }).catch(reason => { // TODO: debug logging -- cgit v1.2.3