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/helpers/createSidebarItems.js

26 lines
592 B

export const createSidebarItems = (initialItems = []) => {
const items = initialItems;
let updateCb = () => {};
const itemsSubscription = {
subscribe: (cb) => {
updateCb = cb;
return () => {
updateCb = () => {};
};
},
getCurrentValue: () => items,
};
const registerSidebarItem = (item) => {
items.push(item);
updateCb();
};
const unregisterSidebarItem = (label) => {
const index = items.findIndex(({ i18nLabel }) => i18nLabel === label);
delete items[index];
updateCb();
};
return { registerSidebarItem, unregisterSidebarItem, itemsSubscription };
};