aboutsummaryrefslogtreecommitdiff
path: root/vnext/src/ui/Thread.js
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2019-06-11 11:01:18 +0300
committerGravatar Vitaly Takmazov2023-01-13 10:37:55 +0300
commitbe48cd1cccacc0cf5b0f6c84455ab54a6a7bf672 (patch)
treee708e8616ffe12536d6f56cc99678a481b675ac3 /vnext/src/ui/Thread.js
parent6c13742f1d01869abc05e22ce2208fce1aafbf1f (diff)
fix links to external users
Diffstat (limited to 'vnext/src/ui/Thread.js')
-rw-r--r--vnext/src/ui/Thread.js20
1 files changed, 18 insertions, 2 deletions
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 (
<div>
<div className="msg-header" style={{ padding: '6px', display: 'flex', alignItems: 'flex-start' }}>
- <Avatar user={msg.user}>
+ <Avatar user={author} link={author.uri}>
<div className="msg-ts">
{msg.replyto > 0 &&
(