diff --git a/app/javascript/dashboard/i18n/locale/en/search.json b/app/javascript/dashboard/i18n/locale/en/search.json index 418572c0c..9044bf5f9 100644 --- a/app/javascript/dashboard/i18n/locale/en/search.json +++ b/app/javascript/dashboard/i18n/locale/en/search.json @@ -14,8 +14,8 @@ "EMPTY_STATE": "No %{item} found for query '%{query}'", "EMPTY_STATE_FULL": "No results found for query '%{query}'", "PLACEHOLDER_KEYBINDING": "/ to focus", - "INPUT_PLACEHOLDER": "Search messages, contacts or conversations", - "EMPTY_STATE_DEFAULT": "Search by conversation id, email, phone number, messages for better search results.", + "INPUT_PLACEHOLDER": "Type 3 or more characters to search", + "EMPTY_STATE_DEFAULT": "Search by conversation id, email, phone number, messages for better search results. ", "BOT_LABEL": "Bot", "READ_MORE": "Read more", "WROTE": "wrote:" diff --git a/app/javascript/dashboard/modules/search/components/SearchTabs.vue b/app/javascript/dashboard/modules/search/components/SearchTabs.vue index 011dff845..1702b159f 100644 --- a/app/javascript/dashboard/modules/search/components/SearchTabs.vue +++ b/app/javascript/dashboard/modules/search/components/SearchTabs.vue @@ -18,12 +18,23 @@ export default { type: Array, default: () => [], }, + selectedTab: { + type: Number, + default: 0, + }, }, data() { return { activeTab: 0, }; }, + watch: { + selectedTab(value, oldValue) { + if (value !== oldValue) { + this.activeTab = this.selectedTab; + } + }, + }, methods: { onTabChange(index) { this.activeTab = index; diff --git a/app/javascript/dashboard/modules/search/components/SearchView.vue b/app/javascript/dashboard/modules/search/components/SearchView.vue index 94862a3cf..cd72625fd 100644 --- a/app/javascript/dashboard/modules/search/components/SearchView.vue +++ b/app/javascript/dashboard/modules/search/components/SearchView.vue @@ -17,11 +17,12 @@
-
+
-
+

{{ $t('SEARCH.EMPTY_STATE_FULL', { query }) }} @@ -157,9 +158,23 @@ export default { }, ]; }, + activeTabIndex() { + const index = this.tabs.findIndex(tab => tab.key === this.selectedTab); + return index >= 0 ? index : 0; + }, showEmptySearchResults() { return ( - this.totalSearchResultsCount === 0 && this.uiFlags.isSearchCompleted + this.totalSearchResultsCount === 0 && + this.uiFlags.isSearchCompleted && + !this.uiFlags.isFetching && + this.query + ); + }, + showResultsSection() { + return ( + (this.uiFlags.isSearchCompleted && + this.totalSearchResultsCount !== 0) || + this.uiFlags.isFetching ); }, isSelectedTabAll() { @@ -175,6 +190,7 @@ export default { }, methods: { onSearch(q) { + this.selectedTab = 'all'; this.query = q; if (!q) { this.$store.dispatch('conversationSearch/clearSearchResults'); diff --git a/app/javascript/dashboard/store/modules/conversationSearch.js b/app/javascript/dashboard/store/modules/conversationSearch.js index 57b993cd1..210081fa1 100644 --- a/app/javascript/dashboard/store/modules/conversationSearch.js +++ b/app/javascript/dashboard/store/modules/conversationSearch.js @@ -61,9 +61,11 @@ export const actions = { isSearchCompleted: false, }); try { - dispatch('contactSearch', { q }); - dispatch('conversationSearch', { q }); - dispatch('messageSearch', { q }); + await Promise.all([ + dispatch('contactSearch', { q }), + dispatch('conversationSearch', { q }), + dispatch('messageSearch', { q }), + ]); } catch (error) { // Ignore error } finally {