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/client/startup/renderMessage/highlightWords.js

28 lines
932 B

import { Meteor } from 'meteor/meteor';
import { Tracker } from 'meteor/tracker';
import { callbacks } from '../../../app/callbacks';
import { getUserPreference } from '../../../app/utils';
Meteor.startup(() => {
Tracker.autorun(() => {
const isEnabled = getUserPreference(Meteor.userId(), 'highlights')?.some((highlight) => highlight?.trim()) ?? false;
if (!isEnabled) {
callbacks.remove('renderMessage', 'highlight-words');
return;
}
const options = {
wordsToHighlight: getUserPreference(Meteor.userId(), 'highlights')
.filter((highlight) => highlight?.trim()),
};
import('../../../app/highlight-words').then(({ createHighlightWordsMessageRenderer }) => {
const renderMessage = createHighlightWordsMessageRenderer(options);
callbacks.remove('renderMessage', 'highlight-words');
callbacks.add('renderMessage', renderMessage, callbacks.priority.MEDIUM + 1, 'highlight-words');
});
});
});