diff options
author | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2020-01-09 15:25:00 +0300 |
---|---|---|
committer | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2020-01-09 15:43:08 +0300 |
commit | 22a8bfdfec779a0ba11d9d74f85de6d4116a9087 (patch) | |
tree | 68e8d904b761d2acf45fd828f399fe23d6ba0cde /src/FilesSidebarTabApp.vue | |
parent | 944c5e5cc9ef9da492ab626b98cfd7c6ce0211c7 (diff) |
Set current participant when joining a conversation in the chat tab
The MessagesList starts getting messages once the current participant
has been set, so it needs to be fetched and set after joining the
conversation (as if the current user is not a participant of the
conversation yet only a limited data about the conversation will be
received). Getting the conversation automatically sets the current
participant, and as both the conversation and the participant will be
needed for the CallButton, which will be added later, the participant is
now set implicitly through the conversation.
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'src/FilesSidebarTabApp.vue')
-rw-r--r-- | src/FilesSidebarTabApp.vue | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/FilesSidebarTabApp.vue b/src/FilesSidebarTabApp.vue index 5a83b4bc6..b5b6d25c3 100644 --- a/src/FilesSidebarTabApp.vue +++ b/src/FilesSidebarTabApp.vue @@ -50,6 +50,7 @@ <script> import { getFileConversation } from './services/filesIntegrationServices' +import { fetchConversation } from './services/conversationsService' import { joinConversation, leaveConversation } from './services/participantsService' import CancelableRequest from './utils/cancelableRequest' import { getCurrentUser } from '@nextcloud/auth' @@ -126,7 +127,15 @@ export default { async joinConversation() { await this.getFileConversation() - joinConversation(this.token) + await joinConversation(this.token) + + // The current participant (which is automatically set when fetching + // the current conversation) is needed for the MessagesList to start + // getting the messages. No need to wait for it, but fetching the + // conversation needs to be done once the user has joined the + // conversation (otherwise only limited data would be received if + // the user was not a participant of the conversation yet). + this.fetchCurrentConversation() }, leaveConversation() { @@ -161,6 +170,15 @@ export default { } }, + async fetchCurrentConversation() { + if (!this.token) { + return + } + + const response = await fetchConversation(this.token) + this.$store.dispatch('addConversation', response.data.ocs.data) + }, + /** * Sets whether the Talk sidebar is supported for the file or not. * |