Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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 .changeset/add_highlithing_to_to_be_replied.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
default: minor
---

Highlight message that you are about to reply to!
22 changes: 20 additions & 2 deletions src/app/components/message/layout/Base.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,30 @@ import * as css from './layout.css';

export const MessageBase = as<'div', css.MessageBaseVariants>(
(
{ className, highlight, notifyHighlight, selected, collapse, autoCollapse, space, ...props },
{
className,
highlight,
notifyHighlight,
selected,
isMarked,
collapse,
autoCollapse,
space,
...props
},
ref
) => (
<div
className={classNames(
css.MessageBase({ highlight, notifyHighlight, selected, collapse, autoCollapse, space }),
css.MessageBase({
highlight,
notifyHighlight,
isMarked,
selected,
collapse,
autoCollapse,
space,
}),
className
)}
{...props}
Expand Down
6 changes: 6 additions & 0 deletions src/app/components/message/layout/layout.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ const SelectedVariant = styleVariants({
backgroundColor: color.Surface.ContainerActive,
},
});
const MarkedVariant = styleVariants({
true: {
backgroundColor: color.Other.Overlay,
},
});

const AutoCollapse = style({
selectors: {
Expand Down Expand Up @@ -118,6 +123,7 @@ export const MessageBase = recipe({
highlight: HighlightVariant,
notifyHighlight: NotifyHighlightVariant,
selected: SelectedVariant,
isMarked: MarkedVariant,
},
defaultVariants: {
space: '400',
Expand Down
6 changes: 6 additions & 0 deletions src/app/features/room/message/Message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ export type MessageProps = {
collapse: boolean;
highlight: boolean;
notifyHighlight?: 'silent' | 'loud';
isMarked?: boolean;
edit?: boolean;
canDelete?: boolean;
canSendReaction?: boolean;
Expand Down Expand Up @@ -333,6 +334,7 @@ function MessageInternal(
collapse,
highlight,
notifyHighlight,
isMarked,
edit,
canDelete,
canSendReaction,
Expand Down Expand Up @@ -876,6 +878,7 @@ function MessageInternal(
highlight={highlight}
notifyHighlight={highlightMentions ? notifyHighlight : undefined}
selected={!!menuAnchor || !!emojiBoardAnchor}
isMarked={isMarked}
{...props}
{...hoverProps}
{...focusWithinProps}
Expand Down Expand Up @@ -1275,6 +1278,7 @@ export type EventProps = {
mEvent: MatrixEvent;
highlight: boolean;
notifyHighlight?: 'silent' | 'loud';
isMarked?: boolean;
canDelete?: boolean;
onReplyClick: (
ev: Parameters<MouseEventHandler<HTMLButtonElement>>[0],
Expand All @@ -1293,6 +1297,7 @@ export const Event = as<'div', EventProps>(
mEvent,
highlight,
notifyHighlight,
isMarked,
collapse,
canDelete,
onReplyClick,
Expand Down Expand Up @@ -1388,6 +1393,7 @@ export const Event = as<'div', EventProps>(
highlight={highlight}
notifyHighlight={highlightMentions ? notifyHighlight : undefined}
selected={!!menuAnchor}
isMarked={isMarked}
{...props}
{...hoverProps}
{...focusWithinProps}
Expand Down
22 changes: 22 additions & 0 deletions src/app/hooks/timeline/useTimelineEventRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ export function useTimelineEventRenderer({
const reactions = reactionRelations?.getSortedAnnotationsByKey();
const hasReactions = reactions && reactions.length > 0;
const highlighted = focusItem?.index === item && focusItem.highlight;
const marked = activeReplyId === mEventId;

const pushActions = pushProcessor.actionsForEvent(mEvent);
let notifyHighlight: 'silent' | 'loud' | undefined;
Expand Down Expand Up @@ -429,6 +430,7 @@ export function useTimelineEventRenderer({
messageSpacing={messageSpacing}
messageLayout={messageLayout}
highlight={highlighted}
isMarked={marked}
notifyHighlight={notifyHighlight}
edit={editId === mEventId}
canDelete={canRedact || (canDeleteOwn && senderId === mx.getUserId())}
Expand Down Expand Up @@ -533,6 +535,7 @@ export function useTimelineEventRenderer({
const reactions = reactionRelations?.getSortedAnnotationsByKey();
const hasReactions = reactions && reactions.length > 0;
const highlighted = focusItem?.index === item && focusItem.highlight;
const marked = activeReplyId === mEventId;
const senderId = mEvent.getSender() ?? '';
const senderDisplayName =
getMemberDisplayName(room, senderId, nicknames) ?? getMxIdLocalPart(senderId) ?? senderId;
Expand All @@ -553,6 +556,7 @@ export function useTimelineEventRenderer({
messageSpacing={messageSpacing}
messageLayout={messageLayout}
highlight={highlighted}
isMarked={marked}
notifyHighlight={notifyHighlight}
edit={editId === mEventId}
canDelete={canRedact || (canDeleteOwn && senderId === mx.getUserId())}
Expand Down Expand Up @@ -703,6 +707,7 @@ export function useTimelineEventRenderer({
const reactions = reactionRelations?.getSortedAnnotationsByKey();
const hasReactions = reactions && reactions.length > 0;
const highlighted = focusItem?.index === item && focusItem.highlight;
const marked = activeReplyId === mEventId;
const senderId = mEvent.getSender() ?? '';
const senderDisplayName =
getMemberDisplayName(room, senderId, nicknames) ?? getMxIdLocalPart(senderId) ?? senderId;
Expand All @@ -718,6 +723,7 @@ export function useTimelineEventRenderer({
messageSpacing={messageSpacing}
messageLayout={messageLayout}
highlight={highlighted}
isMarked={marked}
canDelete={canRedact || (canDeleteOwn && senderId === mx.getUserId())}
canSendReaction={canSendReaction}
canPinEvent={canPinEvent}
Expand Down Expand Up @@ -814,6 +820,7 @@ export function useTimelineEventRenderer({
if (!membershipChanged && hideNickAvatarEvents) return null;

const highlighted = focusItem?.index === item && focusItem.highlight;
const marked = activeReplyId === mEventId;
const parsed = parseMemberEvent(mEvent);

const timeJSX = (
Expand All @@ -833,6 +840,7 @@ export function useTimelineEventRenderer({
room={room}
mEvent={mEvent}
highlight={highlighted}
isMarked={marked}
collapse={collapse}
canDelete={canRedact || mEvent.getSender() === mx.getUserId()}
onReplyClick={onReplyClick}
Expand All @@ -857,6 +865,7 @@ export function useTimelineEventRenderer({
},
[EventType.RoomName]: (mEventId, mEvent, item, timelineSet, collapse) => {
const highlighted = focusItem?.index === item && focusItem.highlight;
const marked = activeReplyId === mEventId;
const senderId = mEvent.getSender() ?? '';
const senderName =
getMemberDisplayName(room, senderId, nicknames) || getMxIdLocalPart(senderId);
Expand All @@ -877,6 +886,7 @@ export function useTimelineEventRenderer({
room={room}
mEvent={mEvent}
highlight={highlighted}
isMarked={marked}
collapse={collapse}
canDelete={canRedact || senderId === mx.getUserId()}
onReplyClick={onReplyClick}
Expand All @@ -902,6 +912,7 @@ export function useTimelineEventRenderer({
},
[EventType.RoomTopic]: (mEventId, mEvent, item, timelineSet, collapse) => {
const highlighted = focusItem?.index === item && focusItem.highlight;
const marked = activeReplyId === mEventId;
const senderId = mEvent.getSender() ?? '';
const senderName =
getMemberDisplayName(room, senderId, nicknames) || getMxIdLocalPart(senderId);
Expand All @@ -923,6 +934,7 @@ export function useTimelineEventRenderer({
room={room}
mEvent={mEvent}
highlight={highlighted}
isMarked={marked}
collapse={collapse}
canDelete={canRedact || senderId === mx.getUserId()}
onReplyClick={onReplyClick}
Expand All @@ -948,6 +960,7 @@ export function useTimelineEventRenderer({
},
[EventType.RoomAvatar]: (mEventId, mEvent, item, timelineSet, collapse) => {
const highlighted = focusItem?.index === item && focusItem.highlight;
const marked = activeReplyId === mEventId;
const senderId = mEvent.getSender() ?? '';
const senderName =
getMemberDisplayName(room, senderId, nicknames) || getMxIdLocalPart(senderId);
Expand All @@ -969,6 +982,7 @@ export function useTimelineEventRenderer({
room={room}
mEvent={mEvent}
highlight={highlighted}
isMarked={marked}
collapse={collapse}
canDelete={canRedact || senderId === mx.getUserId()}
onReplyClick={onReplyClick}
Expand All @@ -994,6 +1008,7 @@ export function useTimelineEventRenderer({
},
[EventType.GroupCallMemberPrefix]: (mEventId, mEvent, item, timelineSet, collapse) => {
const highlighted = focusItem?.index === item && focusItem.highlight;
const marked = activeReplyId === mEventId;
const senderId = mEvent.getSender() ?? '';
const senderName = getMemberDisplayName(room, senderId) || getMxIdLocalPart(senderId);

Expand Down Expand Up @@ -1022,6 +1037,7 @@ export function useTimelineEventRenderer({
room={room}
mEvent={mEvent}
highlight={highlighted}
isMarked={marked}
collapse={collapse}
canDelete={canRedact || senderId === mx.getUserId()}
hideReadReceipts={hideReads}
Expand All @@ -1048,6 +1064,7 @@ export function useTimelineEventRenderer({
[EventType.RoomPinnedEvents]: (mEventId, mEvent, item, timelineSet, collapse) => {
if (!showHiddenEvents) return null;
const highlighted = focusItem?.index === item && focusItem.highlight;
const marked = activeReplyId === mEventId;
const senderId = mEvent.getSender() ?? '';
const senderName =
getMemberDisplayName(room, senderId, nicknames) || getMxIdLocalPart(senderId);
Expand Down Expand Up @@ -1080,6 +1097,7 @@ export function useTimelineEventRenderer({
room={room}
mEvent={mEvent}
highlight={highlighted}
isMarked={marked}
collapse={collapse}
canDelete={canRedact || senderId === mx.getUserId()}
onReplyClick={onReplyClick}
Expand Down Expand Up @@ -1133,6 +1151,7 @@ export function useTimelineEventRenderer({
(mEventId, mEvent, item, timelineSet, collapse) => {
if (!showHiddenEvents) return null;
const highlighted = focusItem?.index === item && focusItem.highlight;
const marked = activeReplyId === mEventId;
const senderId = mEvent.getSender() ?? '';
const senderName =
getMemberDisplayName(room, senderId, nicknames) || getMxIdLocalPart(senderId);
Expand All @@ -1154,6 +1173,7 @@ export function useTimelineEventRenderer({
room={room}
mEvent={mEvent}
highlight={highlighted}
isMarked={marked}
collapse={collapse}
canDelete={canRedact || senderId === mx.getUserId()}
onReplyClick={onReplyClick}
Expand Down Expand Up @@ -1186,6 +1206,7 @@ export function useTimelineEventRenderer({
if (mEvent.isRedaction()) return null;

const highlighted = focusItem?.index === item && focusItem.highlight;
const marked = activeReplyId === mEventId;
const senderId = mEvent.getSender() ?? '';
const senderName =
getMemberDisplayName(room, senderId, nicknames) || getMxIdLocalPart(senderId);
Expand All @@ -1207,6 +1228,7 @@ export function useTimelineEventRenderer({
room={room}
mEvent={mEvent}
highlight={highlighted}
isMarked={marked}
collapse={collapse}
canDelete={canRedact || senderId === mx.getUserId()}
onReplyClick={onReplyClick}
Expand Down
Loading