mirror of
https://github.com/lingble/chatwoot.git
synced 2025-10-30 18:47:51 +00:00
fix: Pagination bug in chat list (#6899)
* fix: Pagination bug in chat list * chore: Review fixes * Improves variable namings --------- Co-authored-by: Nithin David Thomas <1277421+nithindavid@users.noreply.github.com>
This commit is contained in:
@@ -250,6 +250,9 @@ export default {
|
|||||||
...filter,
|
...filter,
|
||||||
attributeName: this.$t(`FILTER.ATTRIBUTES.${filter.attributeI18nKey}`),
|
attributeName: this.$t(`FILTER.ATTRIBUTES.${filter.attributeI18nKey}`),
|
||||||
})),
|
})),
|
||||||
|
// chatsOnView is to store the chats that are currently visible on the screen,
|
||||||
|
// which mirrors the conversationList.
|
||||||
|
chatsOnView: [],
|
||||||
foldersQuery: {},
|
foldersQuery: {},
|
||||||
showAddFoldersModal: false,
|
showAddFoldersModal: false,
|
||||||
showDeleteFoldersModal: false,
|
showDeleteFoldersModal: false,
|
||||||
@@ -349,18 +352,39 @@ export default {
|
|||||||
this.currentPageFilterKey
|
this.currentPageFilterKey
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
activeAssigneeTabCount() {
|
||||||
|
const { activeAssigneeTab } = this;
|
||||||
|
const count = this.assigneeTabItems.find(
|
||||||
|
item => item.key === activeAssigneeTab
|
||||||
|
).count;
|
||||||
|
return count;
|
||||||
|
},
|
||||||
conversationFilters() {
|
conversationFilters() {
|
||||||
return {
|
return {
|
||||||
inboxId: this.conversationInbox ? this.conversationInbox : undefined,
|
inboxId: this.conversationInbox ? this.conversationInbox : undefined,
|
||||||
assigneeType: this.activeAssigneeTab,
|
assigneeType: this.activeAssigneeTab,
|
||||||
status: this.activeStatus,
|
status: this.activeStatus,
|
||||||
page: this.currentPage + 1,
|
page: this.conversationListPagination,
|
||||||
labels: this.label ? [this.label] : undefined,
|
labels: this.label ? [this.label] : undefined,
|
||||||
teamId: this.teamId || undefined,
|
teamId: this.teamId || undefined,
|
||||||
conversationType: this.conversationType || undefined,
|
conversationType: this.conversationType || undefined,
|
||||||
folders: this.hasActiveFolders ? this.savedFoldersValue : undefined,
|
folders: this.hasActiveFolders ? this.savedFoldersValue : undefined,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
conversationListPagination() {
|
||||||
|
const conversationsPerPage = 25;
|
||||||
|
const isNoFiltersOrFoldersAndChatListNotEmpty =
|
||||||
|
!this.hasAppliedFiltersOrActiveFolders && this.chatsOnView !== [];
|
||||||
|
const isUnderPerPage =
|
||||||
|
this.chatsOnView.length < conversationsPerPage &&
|
||||||
|
this.activeAssigneeTabCount < conversationsPerPage &&
|
||||||
|
this.activeAssigneeTabCount > this.chatsOnView.length;
|
||||||
|
|
||||||
|
if (isNoFiltersOrFoldersAndChatListNotEmpty && isUnderPerPage) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return this.currentPage + 1;
|
||||||
|
},
|
||||||
pageTitle() {
|
pageTitle() {
|
||||||
if (this.hasAppliedFilters) {
|
if (this.hasAppliedFilters) {
|
||||||
return this.$t('CHAT_LIST.TAB_HEADING');
|
return this.$t('CHAT_LIST.TAB_HEADING');
|
||||||
@@ -402,7 +426,6 @@ export default {
|
|||||||
} else {
|
} else {
|
||||||
conversationList = [...this.chatLists];
|
conversationList = [...this.chatLists];
|
||||||
}
|
}
|
||||||
|
|
||||||
return conversationList;
|
return conversationList;
|
||||||
},
|
},
|
||||||
activeFolder() {
|
activeFolder() {
|
||||||
@@ -451,6 +474,9 @@ export default {
|
|||||||
this.resetAndFetchData();
|
this.resetAndFetchData();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
chatLists() {
|
||||||
|
this.chatsOnView = this.conversationList;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.$store.dispatch('setChatFilter', this.activeStatus);
|
this.$store.dispatch('setChatFilter', this.activeStatus);
|
||||||
|
|||||||
Reference in New Issue
Block a user