Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/spreed.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Petry <vincent@nextcloud.com>2020-12-01 20:08:19 +0300
committerVincent Petry <vincent@nextcloud.com>2020-12-11 20:15:47 +0300
commitf4d26223b3d22ecf2435c67adccf05629102be7f (patch)
treed4f96fc75b5f5c7dc34f55c7811a1ab3ea33a562
parent9646678ec877b006e784cc8e81c9778f15b11332 (diff)
WIP add listed conversation to the left sidebar results
Signed-off-by: Vincent Petry <vincent@nextcloud.com>
-rw-r--r--src/components/LeftSidebar/LeftSidebar.vue41
-rw-r--r--src/services/conversationsService.js20
2 files changed, 59 insertions, 2 deletions
diff --git a/src/components/LeftSidebar/LeftSidebar.vue b/src/components/LeftSidebar/LeftSidebar.vue
index 0ad10eb99..5af424057 100644
--- a/src/components/LeftSidebar/LeftSidebar.vue
+++ b/src/components/LeftSidebar/LeftSidebar.vue
@@ -44,6 +44,16 @@
@focus="setFocusedIndex" />
</li>
<template v-if="isSearching">
+ <template v-if="searchResultsListedConversations.length !== 0">
+ <Caption
+ :title="t('spreed', 'Listed conversations')" />
+ <li role="presentation">
+ <!-- FIXME: use ConversationsList instead ? -->
+ <ConversationsOptionsList
+ :items="searchResultsListedConversations"
+ @click="joinConversation" />
+ </li>
+ </template>
<template v-if="searchResultsUsers.length !== 0">
<Caption
:title="t('spreed', 'Users')" />
@@ -114,6 +124,7 @@ import {
createOneToOneConversation,
fetchConversations,
searchPossibleConversations,
+ searchListedConversations,
} from '../../services/conversationsService'
import { CONVERSATION } from '../../constants'
import { loadState } from '@nextcloud/initial-state'
@@ -146,7 +157,9 @@ export default {
searchResultsUsers: [],
searchResultsGroups: [],
searchResultsCircles: [],
+ searchResultsListedConversations: [],
contactsLoading: false,
+ listedConversationsLoading: false,
isCirclesEnabled: loadState('talk', 'circles_enabled'),
canStartConversations: loadState('talk', 'start_conversations'),
initialisedConversations: false,
@@ -256,7 +269,7 @@ export default {
}
}, 250),
- async fetchSearchResults() {
+ async fetchPossibleConversations() {
this.contactsLoading = true
const response = await searchPossibleConversations(this.searchText, undefined, !this.canStartConversations)
this.searchResults = response.data.ocs.data
@@ -268,11 +281,37 @@ export default {
this.searchResultsGroups = this.searchResults.filter((match) => match.source === 'groups')
this.searchResultsCircles = this.searchResults.filter((match) => match.source === 'circles')
this.contactsLoading = false
+ },
+
+ async fetchListedConversations() {
+ this.listedConversationsLoading = true
+ const response = await searchListedConversations(this.searchText)
+ if (response.data.ocs.data?.entries?.length) {
+ this.searchResultsListedConversations = response.data.ocs.data.entries.map((result) => {
+ return {
+ // TODO: extract token ?
+ id: result.resourceUrl,
+ label: result.title,
+ icon: result.icon,
+ }
+ })
+ } else {
+ this.searchResultsListedConversations = []
+ }
+ this.listedConversationsLoading = false
+ },
+
+ async fetchSearchResults() {
+ await Promise.all([this.fetchPossibleConversations(), this.fetchListedConversations()])
// If none already focused, focus the first rendered result
this.focusInitialise()
},
+ async joinConversation(item) {
+ console.log('TODO: Implement join conversation: ', item)
+ },
+
/**
* Create a new conversation with the selected group/user/circle
* @param {Object} item The autocomplete suggestion to start a conversation with
diff --git a/src/services/conversationsService.js b/src/services/conversationsService.js
index 4c256c01b..a4b8e41b2 100644
--- a/src/services/conversationsService.js
+++ b/src/services/conversationsService.js
@@ -89,6 +89,23 @@ const checkTalkVersionHash = function(response) {
}
/**
+ * Fetch listed conversations
+ * @param {string} searchText The string that will be used in the search query.
+ */
+const searchListedConversations = async function(searchText) {
+ try {
+ // use search provider to find listed conversations
+ return axios.get(generateOcsUrl('search/providers/talk-listed-conversations', 2) + 'search', {
+ params: {
+ term: searchText,
+ format: 'json',
+ },
+ })
+ } catch (error) {
+ console.debug('Error while searching listedk conversations: ', error)
+ }
+}
+/**
* Fetch possible conversations
* @param {string} searchText The string that will be used in the search query.
* @param {string} [token] The token of the conversation (if any)
@@ -110,7 +127,7 @@ const searchPossibleConversations = async function(searchText, token, onlyUsers)
}
try {
- return await axios.get(generateOcsUrl('core/autocomplete', 2) + `get`, {
+ return axios.get(generateOcsUrl('core/autocomplete', 2) + `get`, {
params: {
search: searchText,
itemType: 'call',
@@ -343,6 +360,7 @@ const changeListable = async function(token, listable) {
export {
fetchConversations,
fetchConversation,
+ searchListedConversations,
searchPossibleConversations,
createOneToOneConversation,
createGroupConversation,