@selfcommunity/react-ui
Version:
React UI Components to integrate a Community created with SelfCommunity Platform.
33 lines (32 loc) • 819 B
JavaScript
/**
* Compare widget priority
* @param w1
* @param w2
*/
export const widgetSort = (w1, w2) => (w1.position > w2.position ? 1 : -1);
/**
* Get unseen notifications from a collection of item
* of type SCNotificationAggregatedType
* @return number
*/
export const getUnseenNotification = (data) => {
let _unseen = [];
if (data && Array.isArray(data)) {
data.map((n) => {
if (n.is_new) {
n.aggregated.map((a) => {
a.is_new && _unseen.push(a);
});
}
});
}
return _unseen;
};
/**
* Get unseen notification counter from a colletion of item
* of type SCNotificationAggregatedType
* @return number
*/
export const getUnseenNotificationCounter = (data) => {
return getUnseenNotification(data).length;
};