mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-01 03:27:52 +00:00
# Pull Request Template ## Description This PR includes store filter parts split from this [Reconnect PR](https://github.com/chatwoot/chatwoot/pull/9453)
31 lines
856 B
JavaScript
31 lines
856 B
JavaScript
import { sortComparator } from './helpers';
|
|
|
|
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;
|
|
},
|
|
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;
|
|
},
|
|
};
|