feat: Add a sort option for conversations waiting for a reply from an agent (#7364)
This commit is contained in:
@@ -10,21 +10,36 @@ export const getSelectedChatConversation = ({
|
||||
}) =>
|
||||
allConversations.filter(conversation => conversation.id === selectedChatId);
|
||||
|
||||
const sortComparator = {
|
||||
latest: (a, b) => b.last_activity_at - a.last_activity_at,
|
||||
sort_on_created_at: (a, b) => a.created_at - b.created_at,
|
||||
sort_on_priority: (a, b) => {
|
||||
return (
|
||||
CONVERSATION_PRIORITY_ORDER[a.priority] -
|
||||
CONVERSATION_PRIORITY_ORDER[b.priority]
|
||||
);
|
||||
},
|
||||
sort_on_waiting_since: (a, b) => {
|
||||
if (!a.waiting_since && !b.waiting_since) {
|
||||
return a.created_at - b.created_at;
|
||||
}
|
||||
|
||||
if (!a.waiting_since) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!b.waiting_since) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return a.waiting_since - b.waiting_since;
|
||||
},
|
||||
};
|
||||
|
||||
// getters
|
||||
const getters = {
|
||||
getAllConversations: ({ allConversations, chatSortFilter }) => {
|
||||
const comparator = {
|
||||
latest: (a, b) => b.last_activity_at - a.last_activity_at,
|
||||
sort_on_created_at: (a, b) => a.created_at - b.created_at,
|
||||
sort_on_priority: (a, b) => {
|
||||
return (
|
||||
CONVERSATION_PRIORITY_ORDER[a.priority] -
|
||||
CONVERSATION_PRIORITY_ORDER[b.priority]
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
return allConversations.sort(comparator[chatSortFilter]);
|
||||
return allConversations.sort(sortComparator[chatSortFilter]);
|
||||
},
|
||||
getSelectedChat: ({ selectedChatId, allConversations }) => {
|
||||
const selectedChat = allConversations.find(
|
||||
|
||||
Reference in New Issue
Block a user