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/Thread.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'vnext/src/ui/Thread.js') 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 (