From be48cd1cccacc0cf5b0f6c84455ab54a6a7bf672 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Tue, 11 Jun 2019 11:01:18 +0300 Subject: fix links to external users --- vnext/src/ui/Avatar.js | 2 +- vnext/src/ui/Thread.js | 20 ++++++++++++++++++-- vnext/src/ui/UserInfo.js | 4 ++-- 3 files changed, 21 insertions(+), 5 deletions(-) (limited to 'vnext/src') diff --git a/vnext/src/ui/Avatar.js b/vnext/src/ui/Avatar.js index dda5449f..ecce4e9f 100644 --- a/vnext/src/ui/Avatar.js +++ b/vnext/src/ui/Avatar.js @@ -24,7 +24,7 @@ function Avatar({ user, style, link, children}) {
- + {user.uname} diff --git a/vnext/src/ui/Thread.js b/vnext/src/ui/Thread.js index b625ecad..30fa0723 100644 --- a/vnext/src/ui/Thread.js +++ b/vnext/src/ui/Thread.js @@ -12,13 +12,16 @@ import Button from './Button'; import { format, embedUrls } from '../utils/embed'; -import { getMessages, comment, markReadTracker } from '../api'; +import { getMessages, comment, markReadTracker, fetchUserUri } from '../api'; import './Thread.css'; +let isMounted; + function Comment({ msg, visitor, active, setActive, postComment }) { const embedRef = useRef(); const msgRef = useRef(); + const [author, setAuthor] = useState(msg.user); useEffect(() => { if (msgRef.current) { embedUrls(msgRef.current.querySelectorAll('a'), embedRef.current); @@ -27,10 +30,23 @@ function Comment({ msg, visitor, active, setActive, postComment }) { } } }, []); + useEffect(() => { + isMounted = true; + if (author.uri) { + fetchUserUri(author.uri).then(response => { + if (isMounted) { + setAuthor(response.data); + } + }); + } + return () => { + isMounted = false; + }; +}, [author.uri]); return (
- +
{msg.replyto > 0 && ( diff --git a/vnext/src/ui/UserInfo.js b/vnext/src/ui/UserInfo.js index 7d84488e..0d06d134 100644 --- a/vnext/src/ui/UserInfo.js +++ b/vnext/src/ui/UserInfo.js @@ -88,10 +88,10 @@ export function UserLink(props) { const [user, setUser] = useState(props.user); useEffect(() => { isMounted = true; - if (!user.uid && user.uri) { + if (user.uri) { fetchUserUri(user.uri).then(response => { if (isMounted) { - setUser({ ...response.data, uid: 66666666 }); + setUser(response.data); } }); } -- cgit v1.2.3