mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-15 18:44:53 +00:00
45 lines
1.3 KiB
JavaScript
45 lines
1.3 KiB
JavaScript
import { sortComparator } from './helpers';
|
|
import camelcaseKeys from 'camelcase-keys';
|
|
|
|
export const getters = {
|
|
getNotifications($state) {
|
|
return Object.values($state.records).sort((n1, n2) => n2.id - n1.id);
|
|
},
|
|
getFilteredNotifications: $state => filters => {
|
|
const sortOrder = filters.sortOrder === 'desc' ? 'newest' : 'oldest';
|
|
const sortedNotifications = Object.values($state.records).sort((n1, n2) =>
|
|
sortComparator(n1, n2, sortOrder)
|
|
);
|
|
return sortedNotifications;
|
|
},
|
|
getFilteredNotificationsV4: $state => filters => {
|
|
const sortOrder = filters.sortOrder === 'desc' ? 'newest' : 'oldest';
|
|
const sortedNotifications = Object.values($state.records).sort((n1, n2) =>
|
|
sortComparator(n1, n2, sortOrder)
|
|
);
|
|
return camelcaseKeys(sortedNotifications, { deep: true });
|
|
},
|
|
getNotificationById: $state => id => {
|
|
return $state.records[id] || {};
|
|
},
|
|
getUIFlags($state) {
|
|
return $state.uiFlags;
|
|
},
|
|
getNotification: $state => id => {
|
|
const notification = $state.records[id];
|
|
return notification || {};
|
|
},
|
|
getMeta: $state => {
|
|
return $state.meta;
|
|
},
|
|
getNotificationFilters($state) {
|
|
return $state.notificationFilters;
|
|
},
|
|
getHasUnreadNotifications: $state => {
|
|
return $state.meta.unreadCount > 0;
|
|
},
|
|
getUnreadCount: $state => {
|
|
return $state.meta.unreadCount;
|
|
},
|
|
};
|