From 8dfe193461b6505005bf61aa4599145c4e230cd8 Mon Sep 17 00:00:00 2001 From: Pranav Raj S Date: Sun, 10 Dec 2023 20:09:17 -0800 Subject: [PATCH] feat: Add infinite loader, option for increasing page size (#8525) Co-authored-by: Muhsin Keloth --- app/finders/conversation_finder.rb | 2 +- .../dashboard/components/ChatList.vue | 73 ++++++++++--------- .../components/IntersectionObserver.vue | 34 +++++++++ 3 files changed, 72 insertions(+), 37 deletions(-) create mode 100644 app/javascript/dashboard/components/IntersectionObserver.vue diff --git a/app/finders/conversation_finder.rb b/app/finders/conversation_finder.rb index cbbd60caa..02c454e04 100644 --- a/app/finders/conversation_finder.rb +++ b/app/finders/conversation_finder.rb @@ -160,6 +160,6 @@ class ConversationFinder :taggings, :inbox, { assignee: { avatar_attachment: [:blob] } }, { contact: { avatar_attachment: [:blob] } }, :team, :contact_inbox ) sort_by = SORT_OPTIONS[params[:sort_by]] || SORT_OPTIONS['latest'] - @conversations.send(sort_by).page(current_page) + @conversations.send(sort_by).page(current_page).per(ENV.fetch('CONVERSATION_RESULTS_PER_PAGE', '25').to_i) end end diff --git a/app/javascript/dashboard/components/ChatList.vue b/app/javascript/dashboard/components/ChatList.vue index 194bf5e5d..9835fadf3 100644 --- a/app/javascript/dashboard/components/ChatList.vue +++ b/app/javascript/dashboard/components/ChatList.vue @@ -126,49 +126,41 @@ @assign-team="onAssignTeamsForBulk" />
-
- -
+
- - - {{ $t('CHAT_LIST.LOAD_MORE_CONVERSATIONS') }} - -

{{ $t('CHAT_LIST.EOF') }}

+
this.$emit('conversation-load')); }, loadMoreConversations() { + if (this.hasCurrentPageEndReached || this.chatListLoading) { + return; + } if (!this.hasAppliedFiltersOrActiveFolders) { this.fetchConversations(); } diff --git a/app/javascript/dashboard/components/IntersectionObserver.vue b/app/javascript/dashboard/components/IntersectionObserver.vue new file mode 100644 index 000000000..215c054ff --- /dev/null +++ b/app/javascript/dashboard/components/IntersectionObserver.vue @@ -0,0 +1,34 @@ + + +