Skip to content

Commit 582d64e

Browse files
Antreesybackportbot[bot]
authored andcommitted
fix(search): immediately show filtered results
fix(search): immediately show filtered results - do not replace rendered list with 'Loading' while waiting for server response Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com> [skip ci]
1 parent 9eac132 commit 582d64e

2 files changed

Lines changed: 11 additions & 25 deletions

File tree

src/components/LeftSidebar/LeftSidebar.vue

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@
262262
ref="searchResults"
263263
class="scroller"
264264
:searchText="searchText"
265-
:contactsLoading="contactsLoading"
265+
:searchResultsLoading="searchResultsLoading"
266266
:conversationsList="conversationsList"
267267
:searchResults="searchResults"
268268
:searchResultsListedConversations="searchResultsListedConversations"
@@ -477,8 +477,7 @@ export default {
477477
searchText: '',
478478
searchResults: [],
479479
searchResultsListedConversations: [],
480-
contactsLoading: false,
481-
listedConversationsLoading: false,
480+
searchResultsLoading: true,
482481
canStartConversations: getTalkConfig('local', 'conversations', 'can-create'),
483482
cancelSearchPossibleConversations: () => {},
484483
cancelSearchListedConversations: () => {},
@@ -758,8 +757,6 @@ export default {
758757
},
759758
760759
async fetchPossibleConversations() {
761-
this.contactsLoading = true
762-
763760
try {
764761
// FIXME: move to conversationsStore
765762
this.cancelSearchPossibleConversations('canceled')
@@ -782,8 +779,6 @@ export default {
782779
this.searchResults = response?.data?.ocs?.data.filter((match) => {
783780
return !(match.source === ATTENDEE.ACTOR_TYPE.USERS && oneToOneMap.includes(match.id))
784781
}) ?? []
785-
786-
this.contactsLoading = false
787782
} catch (exception) {
788783
if (CancelableRequest.isCancel(exception)) {
789784
return
@@ -795,16 +790,13 @@ export default {
795790
796791
async fetchListedConversations() {
797792
try {
798-
this.listedConversationsLoading = true
799-
800793
// FIXME: move to conversationsStore
801794
this.cancelSearchListedConversations('canceled')
802795
const { request, cancel } = CancelableRequest(searchListedConversations)
803796
this.cancelSearchListedConversations = cancel
804797
805798
const response = await request(this.searchText)
806799
this.searchResultsListedConversations = response.data.ocs.data
807-
this.listedConversationsLoading = false
808800
} catch (exception) {
809801
if (CancelableRequest.isCancel(exception)) {
810802
return
@@ -824,7 +816,9 @@ export default {
824816
this.showThreadsList = false
825817
826818
this.resetNavigation()
819+
this.searchResultsLoading = true
827820
await Promise.all([this.fetchPossibleConversations(), this.fetchListedConversations()])
821+
this.searchResultsLoading = false
828822
this.initializeNavigation()
829823
},
830824

src/components/LeftSidebar/SearchConversationsResults/SearchConversationsResults.vue

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,13 @@ const searchResultsVirtual = computed<VirtualListItem[]>(() => {
105105
virtualList.push({ type: 'action', id: 'new_conversation', name: props.searchText, subname: t('spreed', 'New private conversation') })
106106
}
107107
108+
// Add 'Loading' message if there are no results received from the server yet
109+
if (props.searchResultsLoading && !props.searchResultsListedConversations.length && !props.searchResults.length) {
110+
virtualList.push({ type: 'caption', id: 'loading_results_caption', name: t('spreed', 'Other sources') })
111+
virtualList.push({ type: 'hint', id: 'loading_results_hint', hint: t('spreed', 'Loading …') })
112+
return virtualList
113+
}
114+
108115
// Add open conversations section if any
109116
if (props.searchResultsListedConversations.length !== 0) {
110117
virtualList.push({ type: 'caption', id: 'open_conversation_caption', name: t('spreed', 'Open conversations') })
@@ -186,11 +193,6 @@ function iconData(item: ParticipantSearchResult) {
186193
}
187194
}
188195
189-
const hasSourcesWithoutResults = computed(() => {
190-
return !searchResultsVirtual.value.some((item) => item.type === 'user' || item.type === 'group'
191-
|| (item.type === 'circle' && isCirclesEnabled))
192-
})
193-
194196
/**
195197
* Generate the message for the "No results" section
196198
*
@@ -221,10 +223,6 @@ function sourcesWithoutResults(list: SubListType): string {
221223
}
222224
}
223225
224-
const footerMargin = computed(() => {
225-
return isCompact.value ? '0' : '18px' // 54px (item height) - 36px (current height)
226-
})
227-
228226
const iconSize = computed(() => isCompact.value ? AVATAR.SIZE.COMPACT : AVATAR.SIZE.DEFAULT)
229227
</script>
230228

@@ -233,13 +231,7 @@ const iconSize = computed(() => isCompact.value ? AVATAR.SIZE.COMPACT : AVATAR.S
233231
:ref="containerProps.ref"
234232
:style="containerProps.style"
235233
@scroll="containerProps.onScroll">
236-
<NavigationHint
237-
v-if="contactsLoading && !hasSourcesWithoutResults"
238-
:style="{ marginBlockStart: footerMargin }"
239-
tabindex="-1"
240-
:hint="t('spreed', 'Loading …')" />
241234
<ul
242-
v-else
243235
:style="wrapperProps.style">
244236
<template
245237
v-for="item in list"

0 commit comments

Comments
 (0)