From 402428fb4d91f00259c672dc1523c0cb1842c336 Mon Sep 17 00:00:00 2001 From: Nithin David Thomas <1277421+nithindavid@users.noreply.github.com> Date: Tue, 25 Apr 2023 17:59:38 +0530 Subject: [PATCH] feat: Splits search api by resources to improve query time [cw-47] (#6942) * feat: Splits search api by resources to improve query time * Review fixes * Spacing fixes * Update app/javascript/dashboard/modules/search/components/SearchView.vue Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com> * Review fixes * Refactor searchview --------- Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com> Co-authored-by: Muhsin Keloth --- app/javascript/dashboard/api/search.js | 24 ++++ .../search/components/SearchHeader.vue | 5 + .../components/SearchResultContactsList.vue | 10 ++ .../SearchResultConversationsList.vue | 10 ++ .../components/SearchResultMessagesList.vue | 10 ++ .../search/components/SearchResultSection.vue | 19 ++- .../modules/search/components/SearchView.vue | 121 +++++++++--------- .../store/modules/conversationSearch.js | 95 ++++++++++++-- .../dashboard/store/mutation-types.js | 6 + 9 files changed, 222 insertions(+), 78 deletions(-) diff --git a/app/javascript/dashboard/api/search.js b/app/javascript/dashboard/api/search.js index 2e4c3b198..7dc98dcf2 100644 --- a/app/javascript/dashboard/api/search.js +++ b/app/javascript/dashboard/api/search.js @@ -13,6 +13,30 @@ class SearchAPI extends ApiClient { }, }); } + + contacts({ q }) { + return axios.get(`${this.url}/contacts`, { + params: { + q, + }, + }); + } + + conversations({ q }) { + return axios.get(`${this.url}/conversations`, { + params: { + q, + }, + }); + } + + messages({ q }) { + return axios.get(`${this.url}/messages`, { + params: { + q, + }, + }); + } } export default new SearchAPI(); diff --git a/app/javascript/dashboard/modules/search/components/SearchHeader.vue b/app/javascript/dashboard/modules/search/components/SearchHeader.vue index 107cfbc2a..fb5c4a54e 100644 --- a/app/javascript/dashboard/modules/search/components/SearchHeader.vue +++ b/app/javascript/dashboard/modules/search/components/SearchHeader.vue @@ -16,6 +16,7 @@ :title="$t('SEARCH.PLACEHOLDER_KEYBINDING')" :show-close="false" small + class="helper-label" /> @@ -101,4 +102,8 @@ export default { color: var(--s-400); } } + +.helper-label { + margin: 0; +} diff --git a/app/javascript/dashboard/modules/search/components/SearchResultContactsList.vue b/app/javascript/dashboard/modules/search/components/SearchResultContactsList.vue index 1c343451c..5bfd58247 100644 --- a/app/javascript/dashboard/modules/search/components/SearchResultContactsList.vue +++ b/app/javascript/dashboard/modules/search/components/SearchResultContactsList.vue @@ -3,6 +3,8 @@ :title="$t('SEARCH.SECTION.CONTACTS')" :empty="!contacts.length" :query="query" + :show-title="showTitle" + :is-fetching="isFetching" >