@selfcommunity/react-ui
Version:
React UI Components to integrate a Community created with SelfCommunity Platform.
39 lines (38 loc) • 1.15 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.getUnseenNotificationCounter = exports.getUnseenNotification = exports.widgetSort = void 0;
/**
* Compare widget priority
* @param w1
* @param w2
*/
const widgetSort = (w1, w2) => (w1.position > w2.position ? 1 : -1);
exports.widgetSort = widgetSort;
/**
* Get unseen notifications from a collection of item
* of type SCNotificationAggregatedType
* @return number
*/
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;
};
exports.getUnseenNotification = getUnseenNotification;
/**
* Get unseen notification counter from a colletion of item
* of type SCNotificationAggregatedType
* @return number
*/
const getUnseenNotificationCounter = (data) => {
return (0, exports.getUnseenNotification)(data).length;
};
exports.getUnseenNotificationCounter = getUnseenNotificationCounter;
;