|
114 | 114 | @scroll="debounceHandleScroll"> |
115 | 115 | <NcAppNavigationCaption :class="{'hidden-visually': !isSearching}" |
116 | 116 | :title="t('spreed', 'Conversations')" /> |
117 | | - <Conversation v-for="item of conversationsList" |
118 | | - :key="item.id" |
119 | | - :ref="`conversation-${item.token}`" |
120 | | - :item="item" /> |
121 | | - <template v-if="!initialisedConversations"> |
122 | | - <LoadingPlaceholder type="conversations" /> |
| 117 | + |
| 118 | + <!-- Initial Loading --> |
| 119 | + <LoadingPlaceholder v-if="!initialisedConversations" type="conversations" /> |
| 120 | + |
| 121 | + <!-- Conversations List --> |
| 122 | + <template v-else-if="!isSearching"> |
| 123 | + <Conversation v-for="item of filteredConversationsList" |
| 124 | + :key="item.id" |
| 125 | + :ref="`conversation-${item.token}`" |
| 126 | + :item="item" /> |
| 127 | + <Hint v-if="filteredConversationsList.length === 0" :hint="t('spreed', 'No matches')" /> |
123 | 128 | </template> |
124 | | - <Hint v-else-if="noMatchFound" |
125 | | - :hint="t('spreed', 'No matches found')" /> |
126 | | - <template v-if="isSearching"> |
127 | | - <template v-if="!listedConversationsLoading && searchResultsListedConversations.length > 0"> |
| 129 | + |
| 130 | + <!-- Search results --> |
| 131 | + <template v-else-if="isSearching"> |
| 132 | + <!-- Search results: user's conversations --> |
| 133 | + <Conversation v-for="item of searchResultsConversationList" |
| 134 | + :key="item.id" |
| 135 | + :ref="`conversation-${item.token}`" |
| 136 | + :item="item" /> |
| 137 | + <Hint v-if="searchResultsConversationList.length === 0" :hint="t('spreed', 'No matches')" /> |
| 138 | + |
| 139 | + <!-- Search results: listed (open) conversations --> |
| 140 | + <template v-if="!listedConversationsLoading && searchResultsListedConversations.length !== 0"> |
128 | 141 | <NcAppNavigationCaption :title="t('spreed', 'Open conversations')" /> |
129 | 142 | <Conversation v-for="item of searchResultsListedConversations" |
130 | 143 | :key="item.id" |
131 | 144 | :item="item" |
132 | 145 | is-search-result /> |
133 | 146 | </template> |
| 147 | + |
| 148 | + <!-- Search results: users --> |
134 | 149 | <template v-if="searchResultsUsers.length !== 0"> |
135 | 150 | <NcAppNavigationCaption :title="t('spreed', 'Users')" /> |
136 | 151 | <NcListItem v-for="item of searchResultsUsers" |
137 | 152 | :key="item.id" |
138 | 153 | :title="item.label" |
139 | 154 | @click="createAndJoinConversation(item)"> |
140 | 155 | <template #icon> |
141 | | - <ConversationIcon :item="iconData(item)" |
142 | | - :disable-menu="true" /> |
143 | | - </template> |
144 | | - </NcListItem> |
145 | | - </template> |
146 | | - <template v-if="!showStartConversationsOptions"> |
147 | | - <NcAppNavigationCaption v-if="searchResultsUsers.length === 0" |
148 | | - :title="t('spreed', 'Users')" /> |
149 | | - <Hint v-if="contactsLoading" :hint="t('spreed', 'Loading')" /> |
150 | | - <Hint v-else :hint="t('spreed', 'No search results')" /> |
151 | | - </template> |
152 | | - </template> |
153 | | - <template v-if="showStartConversationsOptions"> |
154 | | - <template v-if="searchResultsGroups.length !== 0"> |
155 | | - <NcAppNavigationCaption :title="t('spreed', 'Groups')" /> |
156 | | - <NcListItem v-for="item of searchResultsGroups" |
157 | | - :key="item.id" |
158 | | - :title="item.label" |
159 | | - @click="createAndJoinConversation(item)"> |
160 | | - <template #icon> |
161 | | - <ConversationIcon :item="iconData(item)" |
162 | | - :disable-menu="true" /> |
| 156 | + <ConversationIcon :item="iconData(item)" disable-menu /> |
163 | 157 | </template> |
164 | 158 | </NcListItem> |
165 | 159 | </template> |
166 | 160 |
|
167 | | - <template v-if="searchResultsCircles.length !== 0"> |
168 | | - <NcAppNavigationCaption :title="t('spreed', 'Circles')" /> |
169 | | - <NcListItem v-for="item of searchResultsCircles" |
170 | | - :key="item.id" |
171 | | - :title="item.label" |
172 | | - @click="createAndJoinConversation(item)"> |
173 | | - <template #icon> |
174 | | - <ConversationIcon :item="iconData(item)" |
175 | | - :disable-menu="true" /> |
176 | | - </template> |
177 | | - </NcListItem> |
| 161 | + <!-- Search results: new conversations --> |
| 162 | + <template v-if="canStartConversations"> |
| 163 | + <!-- New conversations: Groups --> |
| 164 | + <template v-if="searchResultsGroups.length !== 0"> |
| 165 | + <NcAppNavigationCaption :title="t('spreed', 'Groups')" /> |
| 166 | + <NcListItem v-for="item of searchResultsGroups" |
| 167 | + :key="item.id" |
| 168 | + :title="item.label" |
| 169 | + @click="createAndJoinConversation(item)"> |
| 170 | + <template #icon> |
| 171 | + <ConversationIcon :item="iconData(item)" disable-menu /> |
| 172 | + </template> |
| 173 | + </NcListItem> |
| 174 | + </template> |
| 175 | + |
| 176 | + <!-- New conversations: Circles --> |
| 177 | + <template v-if="searchResultsCircles.length !== 0"> |
| 178 | + <NcAppNavigationCaption :title="t('spreed', 'Circles')" /> |
| 179 | + <NcListItem v-for="item of searchResultsCircles" |
| 180 | + :key="item.id" |
| 181 | + :title="item.label" |
| 182 | + @click="createAndJoinConversation(item)"> |
| 183 | + <template #icon> |
| 184 | + <ConversationIcon :item="iconData(item)" disable-menu /> |
| 185 | + </template> |
| 186 | + </NcListItem> |
| 187 | + </template> |
178 | 188 | </template> |
179 | 189 |
|
180 | | - <NcAppNavigationCaption v-if="sourcesWithoutResults" |
181 | | - :title="sourcesWithoutResultsList" /> |
| 190 | + <!-- Search results: no results (yet) --> |
| 191 | + <NcAppNavigationCaption v-if="sourcesWithoutResults" :title="sourcesWithoutResultsList" /> |
182 | 192 | <Hint v-if="contactsLoading" :hint="t('spreed', 'Loading')" /> |
183 | 193 | <Hint v-else :hint="t('spreed', 'No search results')" /> |
184 | 194 | </template> |
185 | 195 | </ul> |
186 | 196 | </li> |
| 197 | + |
187 | 198 | <NcButton v-if="!preventFindingUnread && unreadNum > 0" |
188 | 199 | class="unread-mention-button" |
189 | 200 | type="primary" |
@@ -306,37 +317,36 @@ export default { |
306 | 317 |
|
307 | 318 | computed: { |
308 | 319 | conversationsList() { |
309 | | - let conversations = this.$store.getters.conversationsList |
| 320 | + return this.$store.getters.conversationsList |
| 321 | + }, |
| 322 | +
|
| 323 | + searchResultsConversationList() { |
310 | 324 | if (this.searchText !== '') { |
311 | 325 | const lowerSearchText = this.searchText.toLowerCase() |
312 | | - conversations = conversations.filter(conversation => |
| 326 | + return this.conversationsList.filter(conversation => |
313 | 327 | conversation.displayName.toLowerCase().includes(lowerSearchText) |
314 | | - || conversation.name.toLowerCase().includes(lowerSearchText) |
| 328 | + || conversation.name.toLowerCase().includes(lowerSearchText) |
315 | 329 | ) |
316 | | - } else if (this.isFiltered === 'unread') { |
317 | | - conversations = conversations.filter(conversation => conversation.unreadMessages > 0) |
| 330 | + } else { |
| 331 | + return [] |
| 332 | + } |
| 333 | + }, |
| 334 | +
|
| 335 | + filteredConversationsList() { |
| 336 | + if (this.isFiltered === 'unread') { |
| 337 | + return this.conversationsList.filter(conversation => conversation.unreadMessages > 0) |
318 | 338 | } else if (this.isFiltered === 'mentions') { |
319 | | - conversations = conversations.filter(conversation => conversation.unreadMention || (conversation.unreadMessages > 0 |
| 339 | + return this.conversationsList.filter(conversation => conversation.unreadMention || (conversation.unreadMessages > 0 |
320 | 340 | && (conversation.type === CONVERSATION.TYPE.ONE_TO_ONE || conversation.type === CONVERSATION.TYPE.ONE_TO_ONE_FORMER))) |
| 341 | + } else { |
| 342 | + return this.conversationsList |
321 | 343 | } |
322 | | -
|
323 | | - // FIXME: this modifies the original array, |
324 | | - // maybe should act on a copy or sort already within the store ? |
325 | | - return conversations.sort(this.sortConversations) |
326 | 344 | }, |
327 | 345 |
|
328 | 346 | isSearching() { |
329 | 347 | return this.searchText !== '' |
330 | 348 | }, |
331 | 349 |
|
332 | | - noMatchFound() { |
333 | | - return (this.searchText || this.isFiltered) && !this.conversationsList.length |
334 | | - }, |
335 | | -
|
336 | | - showStartConversationsOptions() { |
337 | | - return this.isSearching && this.canStartConversations |
338 | | - }, |
339 | | -
|
340 | 350 | sourcesWithoutResults() { |
341 | 351 | return !this.searchResultsUsers.length |
342 | 352 | || !this.searchResultsGroups.length |
@@ -563,14 +573,6 @@ export default { |
563 | 573 | emit('show-settings') |
564 | 574 | }, |
565 | 575 |
|
566 | | - sortConversations(conversation1, conversation2) { |
567 | | - if (conversation1.isFavorite !== conversation2.isFavorite) { |
568 | | - return conversation1.isFavorite ? -1 : 1 |
569 | | - } |
570 | | -
|
571 | | - return conversation2.lastActivity - conversation1.lastActivity |
572 | | - }, |
573 | | -
|
574 | 576 | /** |
575 | 577 | * @param {object} [options] Options for conversation refreshing |
576 | 578 | * @param {string} [options.token] The conversation token that got update |
|
0 commit comments