Skip to content

Commit

Permalink
chore: remove meteor.startup from jump-to-star-message
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinSchoeler committed Nov 21, 2024
1 parent 726cfbe commit f95f668
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import React, { memo, useMemo, useRef } from 'react';

import MessageActionMenu from './MessageActionMenu';
import MessageToolbarStarsActionMenu from './MessageToolbarStarsActionMenu';
import { useJumpToStarMessage } from './useJumpToStarMessage';
import { useNewDiscussionMessageAction } from './useNewDiscussionMessageAction';
import { useWebDAVMessageAction } from './useWebDAVMessageAction';
import type { MessageActionContext } from '../../../../app/ui-utils/client/lib/MessageAction';
Expand Down Expand Up @@ -87,6 +88,7 @@ const MessageToolbar = ({
// TODO: move this to another place
useWebDAVMessageAction();
useNewDiscussionMessageAction();
useJumpToStarMessage();

const actionsQueryResult = useQuery(['rooms', room._id, 'messages', message._id, 'actions'] as const, async () => {
const props = { message, room, user, subscription, settings: mapSettings, chat };
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { useSetting } from '@rocket.chat/ui-contexts';
import { useEffect } from 'react';

import { MessageAction } from '../../../../app/ui-utils/client/lib/MessageAction';
import { setMessageJumpQueryStringParameter } from '../../../lib/utils/setMessageJumpQueryStringParameter';

export const useJumpToStarMessage = () => {
const allowStarring = useSetting('Message_AllowStarring');

useEffect(() => {
MessageAction.addButton({
id: 'jump-to-star-message',
icon: 'jump',
label: 'Jump_to_message',
context: ['starred', 'threads', 'message-mobile', 'videoconf-threads'],
action(_, { message }) {
setMessageJumpQueryStringParameter(message._id);
},
condition({ message, subscription, user }) {
if (subscription == null || !allowStarring) {
return false;
}

return Boolean(message.starred?.find((star) => star._id === user?._id));
},
order: 100,
group: 'message',
});

return () => {
MessageAction.removeButton('jump-to-star-message');
};
}, [allowStarring]);
};
1 change: 0 additions & 1 deletion apps/meteor/client/startup/actionButtons/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import './jumpToMessage';
import './jumpToPinMessage';
import './jumpToSearchMessage';
import './jumpToStarMessage';
import './permalinkPinned';
import './permalinkStar';
import './pinMessage';
Expand Down
26 changes: 0 additions & 26 deletions apps/meteor/client/startup/actionButtons/jumpToStarMessage.ts

This file was deleted.

0 comments on commit f95f668

Please sign in to comment.