-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathmessages.tsx
More file actions
91 lines (90 loc) · 2.75 KB
/
Copy pathmessages.tsx
File metadata and controls
91 lines (90 loc) · 2.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import cx from 'classnames';
import moment from 'moment';
import { PortalNavBar } from '@/services/juxt-web/views/portal/navbar';
import {
PortalPageBody,
PortalRoot
} from '@/services/juxt-web/views/portal/root';
import type { ReactNode } from 'react';
import type {
ConversationUserModel,
MessagesViewProps
} from '@/services/juxt-web/views/web/messages';
export function PortalMessagesView(props: MessagesViewProps): ReactNode {
return (
<PortalRoot title={props.ctx.lang.global.messages}>
<PortalNavBar ctx={props.ctx} selection={3} />
<PortalPageBody>
<header id="header">
<h1 id="page-title">{props.ctx.lang.global.messages}</h1>
</header>
<div className="body-content" id="messages-list">
<ul className="list-content-with-icon-and-text arrow-list">
{props.conversations.length === 0
? (
<p className="no-posts-text">
{props.ctx.lang.messages.coming_soon}
</p>
)
: (
props.conversations.map((convo) => {
let userObj: ConversationUserModel | null = null;
let me: ConversationUserModel | null = null;
if (convo.users[0].pid === props.ctx.pid) {
userObj = convo.users[1];
me = convo.users[0];
} else if (convo.users[1].pid === props.ctx.pid) {
userObj = convo.users[0];
me = convo.users[1];
}
if (!me || !userObj) {
return null;
}
if (!userObj.pid || !me.pid) {
return null;
} // Prevent rendering with incomplete data
return (
<li>
<a
href={`/users/show?pid=${userObj.pid}`}
data-pjax="#body"
className="icon-container trigger"
>
<img
src={`${props.ctx.cdnUrl}/mii/${userObj.pid}/normal_face.png`}
className={cx('icon', {
verified: userObj.official
})}
/>
</a>
<a
href={`/friend_messages/${convo.id}`}
data-pjax="#body"
className="arrow-button"
>
</a>
<div className="body">
<p className="title">
<span className="nick-name">
{props.ctx.usersMap.get(userObj.pid)}
</span>
<span className="id-name">
@
{props.ctx.usersMap.get(userObj.pid)}
</span>
</p>
<span className="timestamp">
{moment(convo.last_updated).fromNow()}
</span>
<p className="text">{convo.message_preview}</p>
</div>
</li>
);
})
)}
</ul>
</div>
</PortalPageBody>
</PortalRoot>
);
}