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.ts

35 lines
1006 B

import { Meteor } from 'meteor/meteor';
import { Tracker } from 'meteor/tracker';
import { callbacks } from '../../../app/callbacks/client';
import { getUserPreference } from '../../../app/utils/client';
Meteor.startup(() => {
Tracker.autorun(() => {
const highlights: (string | undefined)[] | undefined = getUserPreference(
Meteor.userId(),
'highlights',
);
const isEnabled = highlights?.some((highlight) => highlight?.trim()) ?? false;
if (!isEnabled) {
callbacks.remove('renderMessage', 'highlight-words');
return;
}
const options = {
wordsToHighlight: 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',
);
});
});
});