Compare commits

...
3 changed files with 35 additions and 24 deletions
@@ -249,7 +249,7 @@ const activeAssigneeTabCount = computed(() => {
});
const conversationListPagination = computed(() => {
const conversationsPerPage = 25;
const conversationsPerPage = wootConstants.CONVERSATIONS_PER_PAGE;
const hasChatsOnView =
chatsOnView.value &&
Array.isArray(chatsOnView.value) &&
@@ -339,7 +339,10 @@ const conversationList = computed(() => {
});
}
return localConversationList;
// Clip to current page size to fix pagination order bug
const maxItems =
currentFiltersPage.value * wootConstants.CONVERSATIONS_PER_PAGE;
return localConversationList.slice(0, maxItems);
});
const showEndOfListMessage = computed(() => {
@@ -1,5 +1,6 @@
export default {
GRAVATAR_URL: 'https://www.gravatar.com/avatar/',
CONVERSATIONS_PER_PAGE: 25,
ASSIGNEE_TYPE: {
ME: 'me',
UNASSIGNED: 'unassigned',
@@ -75,14 +75,17 @@ const getters = {
getMineChats: (_state, _, __, rootGetters) => activeFilters => {
const currentUserID = rootGetters.getCurrentUser?.id;
return _state.allConversations.filter(conversation => {
const { assignee } = conversation.meta;
const isAssignedToMe = assignee && assignee.id === currentUserID;
const shouldFilter = applyPageFilters(conversation, activeFilters);
const isChatMine = isAssignedToMe && shouldFilter;
// Sort after filtering so tab lists keep server pagination order despite merge appends.
return _state.allConversations
.filter(conversation => {
const { assignee } = conversation.meta;
const isAssignedToMe = assignee && assignee.id === currentUserID;
const shouldFilter = applyPageFilters(conversation, activeFilters);
const isChatMine = isAssignedToMe && shouldFilter;
return isChatMine;
});
return isChatMine;
})
.sort((a, b) => sortComparator(a, b, _state.chatSortFilter));
},
getAppliedConversationFiltersV2: _state => {
// TODO: Replace existing one with V2 after migrating the filters to use camelcase
@@ -96,11 +99,13 @@ const getters = {
return hasAppliedFilters ? filterQueryGenerator(_state.appliedFilters) : [];
},
getUnAssignedChats: _state => activeFilters => {
return _state.allConversations.filter(conversation => {
const isUnAssigned = !conversation.meta.assignee;
const shouldFilter = applyPageFilters(conversation, activeFilters);
return isUnAssigned && shouldFilter;
});
return _state.allConversations
.filter(conversation => {
const isUnAssigned = !conversation.meta.assignee;
const shouldFilter = applyPageFilters(conversation, activeFilters);
return isUnAssigned && shouldFilter;
})
.sort((a, b) => sortComparator(a, b, _state.chatSortFilter));
},
getAllStatusChats: (_state, _, __, rootGetters) => activeFilters => {
const currentUser = rootGetters.getCurrentUser;
@@ -110,17 +115,19 @@ const getters = {
const permissions = getUserPermissions(currentUser, currentAccountId);
const userRole = getUserRole(currentUser, currentAccountId);
return _state.allConversations.filter(conversation => {
const shouldFilter = applyPageFilters(conversation, activeFilters);
const allowedForRole = applyRoleFilter(
conversation,
userRole,
permissions,
currentUserId
);
return _state.allConversations
.filter(conversation => {
const shouldFilter = applyPageFilters(conversation, activeFilters);
const allowedForRole = applyRoleFilter(
conversation,
userRole,
permissions,
currentUserId
);
return shouldFilter && allowedForRole;
});
return shouldFilter && allowedForRole;
})
.sort((a, b) => sortComparator(a, b, _state.chatSortFilter));
},
getChatListLoadingStatus: ({ listLoadingStatus }) => listLoadingStatus,
getAllMessagesLoaded(_state) {