The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/apps/meteor/client/startup/actionButtons/permalinkStar.ts

35 lines
1.0 KiB

import { Meteor } from 'meteor/meteor';
import { MessageAction } from '../../../app/ui-utils/client';
import { t } from '../../../app/utils/lib/i18n';
import { dispatchToastMessage } from '../../lib/toast';
import { messageArgs } from '../../lib/utils/messageArgs';
Meteor.startup(() => {
MessageAction.addButton({
id: 'permalink-star',
icon: 'permalink',
label: 'Get_link',
// classes: 'clipboard',
context: ['starred', 'threads'],
async action(_, props) {
try {
const { message = messageArgs(this).msg } = props;
const permalink = await MessageAction.getPermaLink(message._id);
navigator.clipboard.writeText(permalink);
dispatchToastMessage({ type: 'success', message: t('Copied') });
} catch (e) {
dispatchToastMessage({ type: 'error', message: e });
}
},
condition({ message, subscription, user }) {
if (subscription == null) {
return false;
}
return Boolean(message.starred?.find((star) => star._id === user?._id));
},
order: 101,
group: 'menu',
});
});