aboutsummaryrefslogtreecommitdiff
path: root/vnext/src
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
parent6c13742f1d01869abc05e22ce2208fce1aafbf1f (diff)
fix links to external users
Diffstat (limited to 'vnext/src')
-rw-r--r--vnext/src/ui/Avatar.js2
-rw-r--r--vnext/src/ui/Thread.js20
-rw-r--r--vnext/src/ui/UserInfo.js4
3 files changed, 21 insertions, 5 deletions
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}) {
</div>
<div style={{ display: 'flex', flexDirection: 'column', justifyContent: 'center' }}>
<span>
- <Link to={{ pathname: `/${user.uname}/` }}>
+ <Link to={{ pathname: link || `/${user.uname}/` }}>
<span>{user.uname}</span>
</Link>
</span>
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 &&
(
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);
}
});
}