Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Show displayname in non-narrow thread summeries #8036

Merged
merged 5 commits into from
Mar 11, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions res/css/views/rooms/_EventTile.scss
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,11 @@ $left-gutter: 64px;
width: initial;
}

.mx_ThreadInfo_sender {
margin-left: 8px;
font-weight: $font-semi-bold;
}

.mx_ThreadInfo_content {
text-overflow: ellipsis;
overflow: hidden;
Expand Down
12 changes: 10 additions & 2 deletions src/components/views/rooms/ThreadSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,17 @@ const ThreadSummary = ({ mxEvent, thread }: IProps) => {
<span className="mx_ThreadInfo_threads-amount">
{ countSection }
</span>
<ThreadMessagePreview thread={thread} />
<ThreadMessagePreview thread={thread} showDisplayname={!roomContext.narrow} />
</AccessibleButton>
);
};

export const ThreadMessagePreview = ({ thread }: Pick<IProps, "thread">) => {
interface IPreviewProps {
thread: Thread;
showDisplayname?: boolean;
}

export const ThreadMessagePreview = ({ thread, showDisplayname = false }: IPreviewProps) => {
const cli = useContext(MatrixClientContext);
const lastReply = useTypedEventEmitterState(thread, ThreadEvent.Update, () => thread.replyToEvent);
const preview = useAsyncMemo(async () => {
Expand All @@ -85,6 +90,9 @@ export const ThreadMessagePreview = ({ thread }: Pick<IProps, "thread">) => {
height={24}
className="mx_ThreadInfo_avatar"
/>
{ showDisplayname && <div className="mx_ThreadInfo_sender">
{ sender?.name ?? lastReply.getSender() }
</div> }
<div className="mx_ThreadInfo_content">
<span className="mx_ThreadInfo_message-preview">
{ preview }
Expand Down