From 3662df0e73fc33df8db6a6b706b99e2c262c46f6 Mon Sep 17 00:00:00 2001 From: Matilde Park Date: Fri, 11 Dec 2020 11:59:53 -0500 Subject: [PATCH 1/3] chat: send correct timestamp to daybreak Fixes #4127. --- pkg/interface/src/views/apps/chat/components/ChatMessage.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/interface/src/views/apps/chat/components/ChatMessage.tsx b/pkg/interface/src/views/apps/chat/components/ChatMessage.tsx index 28c55e6066..9ee6e71d43 100644 --- a/pkg/interface/src/views/apps/chat/components/ChatMessage.tsx +++ b/pkg/interface/src/views/apps/chat/components/ChatMessage.tsx @@ -144,12 +144,12 @@ export default class ChatMessage extends Component { style={style} mb={1} > - {dayBreak && !isLastRead ? : null} + {dayBreak && !isLastRead ? : null} {renderSigil ? : } {isLastRead - ? + ? : null} ); From 4530b59dd9685127dd0091d7461a1b091c71d514 Mon Sep 17 00:00:00 2001 From: Matilde Park Date: Fri, 11 Dec 2020 12:09:57 -0500 Subject: [PATCH 2/3] landscape: mentions respect calmengine Fixes #4130. --- .../apps/chat/components/ChatMessage.tsx | 19 +++++++++++++++---- .../src/views/components/CommentItem.tsx | 2 ++ .../src/views/components/MentionText.tsx | 16 ++++++++++------ 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/pkg/interface/src/views/apps/chat/components/ChatMessage.tsx b/pkg/interface/src/views/apps/chat/components/ChatMessage.tsx index 9ee6e71d43..fe47d479c7 100644 --- a/pkg/interface/src/views/apps/chat/components/ChatMessage.tsx +++ b/pkg/interface/src/views/apps/chat/components/ChatMessage.tsx @@ -261,6 +261,8 @@ export class MessageWithSigil extends PureComponent { measure={measure} fontSize={fontSize} group={group} + hideNicknames={hideNicknames} + hideAvatars={hideAvatars} />)} @@ -276,16 +278,25 @@ const ContentBox = styled(Box)` `; -export const MessageWithoutSigil = ({ timestamp, contacts, msg, remoteContentPolicy, measure, group }) => ( +export const MessageWithoutSigil = ({ timestamp, contacts, msg, remoteContentPolicy, measure, group, hideNicknames, hideAvatars }) => ( <> {timestamp} - {msg.contents.map(c => ())} + {msg.contents.map((c, i) => ( + ))} ); -export const MessageContent = ({ content, contacts, remoteContentPolicy, measure, fontSize, group }) => { +export const MessageContent = ({ content, contacts, remoteContentPolicy, measure, fontSize, group, hideNicknames, hideAvatars }) => { if ('code' in content) { return ; } else if ('url' in content) { @@ -314,7 +325,7 @@ export const MessageContent = ({ content, contacts, remoteContentPolicy, measure } else if ('text' in content) { return ; } else if ('mention' in content) { - return + return } else { return null; } diff --git a/pkg/interface/src/views/components/CommentItem.tsx b/pkg/interface/src/views/components/CommentItem.tsx index 22dabde859..d61cd352d5 100644 --- a/pkg/interface/src/views/components/CommentItem.tsx +++ b/pkg/interface/src/views/components/CommentItem.tsx @@ -82,6 +82,8 @@ export function CommentItem(props: CommentItemProps) { group={group} content={post?.contents} remoteContentPolicy={remoteContentPolicy} + hideNicknames={props.hideNicknames} + hideAvatars={props.hideAvatars} /> diff --git a/pkg/interface/src/views/components/MentionText.tsx b/pkg/interface/src/views/components/MentionText.tsx index 1bbb8fbaf7..4d4f07b754 100644 --- a/pkg/interface/src/views/components/MentionText.tsx +++ b/pkg/interface/src/views/components/MentionText.tsx @@ -17,9 +17,11 @@ interface MentionTextProps { content: Content[]; group: Group; remoteContentPolicy: LocalUpdateRemoteContentPolicy; + hideNicknames: boolean; + hideAvatars: boolean; } export function MentionText(props: MentionTextProps) { - const { content, contacts, group } = props; + const { content, contacts, group, hideNicknames } = props; return ( <> @@ -36,7 +38,7 @@ export function MentionText(props: MentionTextProps) { ); } else if ("mention" in c) { return ( - + ); } return null; @@ -49,10 +51,12 @@ export function Mention(props: { ship: string; contacts: Contacts; group: Group; + hideNicknames: boolean; + hideAvatars: boolean; }) { - const { contacts, ship } = props; + const { contacts, ship, hideNicknames, hideAvatars } = props; const contact = contacts[ship]; - const showNickname = !!contact?.nickname; + const showNickname = (Boolean(contact?.nickname) && !hideNicknames); const name = showNickname ? contact?.nickname : cite(ship); const [showOverlay, setShowOverlay] = useState(false); const onDismiss = useCallback(() => { @@ -79,8 +83,8 @@ export function Mention(props: { color={`#${uxToHex(contact?.color ?? '0x0')}`} group={group} onDismiss={onDismiss} - hideAvatars={false} - hideNicknames={false} + hideAvatars={hideAvatars || false} + hideNicknames={hideNicknames} history={history} /> )} From 38c66dc06afd33a0027995f4ce13c4afdc7ee97c Mon Sep 17 00:00:00 2001 From: Matilde Park Date: Fri, 11 Dec 2020 14:04:16 -0500 Subject: [PATCH 3/3] landscape: mentions avoid passing entire contacts We don't need 2,000 objects inside each mention. --- .../views/apps/chat/components/ChatMessage.tsx | 2 +- .../src/views/components/MentionText.tsx | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/pkg/interface/src/views/apps/chat/components/ChatMessage.tsx b/pkg/interface/src/views/apps/chat/components/ChatMessage.tsx index fe47d479c7..d2565defc7 100644 --- a/pkg/interface/src/views/apps/chat/components/ChatMessage.tsx +++ b/pkg/interface/src/views/apps/chat/components/ChatMessage.tsx @@ -325,7 +325,7 @@ export const MessageContent = ({ content, contacts, remoteContentPolicy, measure } else if ('text' in content) { return ; } else if ('mention' in content) { - return + return } else { return null; } diff --git a/pkg/interface/src/views/components/MentionText.tsx b/pkg/interface/src/views/components/MentionText.tsx index 4d4f07b754..18e212a56c 100644 --- a/pkg/interface/src/views/components/MentionText.tsx +++ b/pkg/interface/src/views/components/MentionText.tsx @@ -2,6 +2,7 @@ import React, { useState, useCallback } from "react"; import _ from "lodash"; import { Text, Box } from "@tlon/indigo-react"; import { + Contact, Contacts, Content, LocalUpdateRemoteContentPolicy, @@ -13,7 +14,8 @@ import { ProfileOverlay } from "./ProfileOverlay"; import {useHistory} from "react-router-dom"; interface MentionTextProps { - contacts: Contacts; + contact?: Contact; + contacts?: Contacts; content: Content[]; group: Group; remoteContentPolicy: LocalUpdateRemoteContentPolicy; @@ -21,7 +23,7 @@ interface MentionTextProps { hideAvatars: boolean; } export function MentionText(props: MentionTextProps) { - const { content, contacts, group, hideNicknames } = props; + const { content, contacts, contact, group, hideNicknames, hideAvatars } = props; return ( <> @@ -38,7 +40,7 @@ export function MentionText(props: MentionTextProps) { ); } else if ("mention" in c) { return ( - + ); } return null; @@ -49,13 +51,17 @@ export function MentionText(props: MentionTextProps) { export function Mention(props: { ship: string; - contacts: Contacts; + contact: Contact; + contacts?: Contacts; group: Group; hideNicknames: boolean; hideAvatars: boolean; }) { const { contacts, ship, hideNicknames, hideAvatars } = props; - const contact = contacts[ship]; + let { contact } = props; + + contact = (contact?.nickname) ? contact : contacts?.[ship]; + const showNickname = (Boolean(contact?.nickname) && !hideNicknames); const name = showNickname ? contact?.nickname : cite(ship); const [showOverlay, setShowOverlay] = useState(false);