Skip to content

Commit

Permalink
Lift message selecting logic
Browse files Browse the repository at this point in the history
  • Loading branch information
tassoevan committed Dec 10, 2024
1 parent 8c4dabb commit ebf5196
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import { useMessageActionAppsActionButtons } from '../../../hooks/useAppActionBu
import { useEmbeddedLayout } from '../../../hooks/useEmbeddedLayout';
import { roomsQueryKeys } from '../../../lib/queryKeys';
import EmojiElement from '../../../views/composer/EmojiPicker/EmojiElement';
import { useIsSelecting } from '../../../views/room/MessageList/contexts/SelectedMessagesContext';

const getMessageContext = (message: IMessage, room: IRoom, context?: MessageActionContext): MessageActionContext => {
if (context) {
Expand Down Expand Up @@ -108,19 +107,16 @@ const MessageToolbar = ({
useForwardMessageAction(message);
useJumpToMessageContextAction(message, {
id: 'jump-to-message',
order: 100,
context: ['mentions', 'threads', 'videoconf-threads', 'message-mobile', 'search'],
});
useJumpToMessageContextAction(message, {
id: 'jump-to-pin-message',
order: 100,
hidden: !subscription,
context: ['pinned', 'direct'],
});
useJumpToMessageContextAction(message, {
id: 'jump-to-star-message',
hidden: !allowStarring || !subscription,
order: 100,
context: ['starred'],
});

Expand Down Expand Up @@ -166,9 +162,7 @@ const MessageToolbar = ({
keepPreviousData: true,
});

const selecting = useIsSelecting();

if (selecting || (!data?.message.length && !data?.menu.length)) {
if (!data?.message.length && !data?.menu.length) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { setMessageJumpQueryStringParameter } from '../../../lib/utils/setMessag

export const useJumpToMessageContextAction = (
message: IMessage,
{ id, order, hidden, context }: { id: string; order: number; hidden?: boolean; context: MessageActionContext[] },
{ id, hidden, context }: { id: string; hidden?: boolean; context: MessageActionContext[] },
) => {
useEffect(() => {
if (hidden) {
Expand All @@ -22,12 +22,12 @@ export const useJumpToMessageContextAction = (
async action() {
setMessageJumpQueryStringParameter(message._id);
},
order,
order: 100,
group: 'message',
});

return () => {
MessageAction.removeButton(id);
};
}, [hidden, context, id, message._id, order]);
}, [hidden, context, id, message._id]);
};
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ const RoomMessage = ({
<RoomMessageContent message={message} unread={unread} mention={mention} all={all} searchText={searchText} />
)}
</MessageContainer>
{!message.private && message?.e2e !== 'pending' && <MessageToolbarHolder message={message} context={context} />}
{!message.private && message?.e2e !== 'pending' && !selecting && <MessageToolbarHolder message={message} context={context} />}
</Message>
);
};
Expand Down

0 comments on commit ebf5196

Please sign in to comment.