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/app/ui-message/client/popup/customMessagePopups.js

29 lines
844 B

import { ReactiveVar } from 'meteor/reactive-var';
import { Tracker } from 'meteor/tracker';
export const customMessagePopups = new ReactiveVar([]);
const nonReactiveGetFunc = () => Tracker.nonreactive(() => customMessagePopups.get());
export const addMessagePopup = (configGetter, name) => {
customMessagePopups.set([
...nonReactiveGetFunc(),
{
configGetter,
name,
},
]);
};
export const removeMessagePopup = (popupName) => {
const customMessagePopupsList = nonReactiveGetFunc();
const element = customMessagePopupsList.findIndex(({ name }) => name === popupName);
if (element < 0) {
return;
}
const listWithRemovedElement = [
...customMessagePopupsList.slice(0, element),
...customMessagePopupsList.slice(element + 1, customMessagePopupsList.length),
];
customMessagePopups.set([...listWithRemovedElement]);
};