summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Calviño Sánchez <danxuliu@gmail.com>2022-12-19 01:46:39 +0100
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2023-01-31 05:00:56 +0100
commit8479b8a18cd5f0b3782864e37956ec3bc0b5681f (patch)
tree8f08a844f8f11048edec3067299743ba3416afbf
parentcee13cb8cf10f5a4c9437731732df8a2e10ffcfe (diff)
Handle "switchto" message in WebUI
When the client receives a message to switch to a different room the WebUI joins that room. If the WebUI was already in a call it will automatically join the call in the target room; in that case the call view will be kept shown during the switch, rather than showing the chat while leaving the previous call and joining the new room to then show the call again when joining the call in the target room. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
-rw-r--r--src/App.vue34
-rw-r--r--src/mixins/isInCall.js5
-rw-r--r--src/store/callViewStore.js9
-rw-r--r--src/utils/signaling.js5
4 files changed, 50 insertions, 3 deletions
diff --git a/src/App.vue b/src/App.vue
index b06b40ee7..514a20760 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -65,7 +65,7 @@ import UploadEditor from './components/UploadEditor.vue'
import SettingsDialog from './components/SettingsDialog/SettingsDialog.vue'
import ConversationSettingsDialog from './components/ConversationSettings/ConversationSettingsDialog.vue'
import '@nextcloud/dialogs/styles/toast.scss'
-import { CONVERSATION } from './constants.js'
+import { CONVERSATION, PARTICIPANT } from './constants.js'
import DeviceChecker from './components/DeviceChecker/DeviceChecker.vue'
import isMobile from '@nextcloud/vue/dist/Mixins/isMobile.js'
@@ -263,6 +263,38 @@ export default {
}
})
+ EventBus.$on('switch-to-conversation', (params) => {
+ if (this.isInCall) {
+ this.$store.dispatch('setForceCallView', true)
+
+ EventBus.$once('joined-conversation', async ({ token }) => {
+ if (params.token !== token) {
+ return
+ }
+
+ const conversation = this.$store.getters.conversation(token)
+
+ let flags = PARTICIPANT.CALL_FLAG.IN_CALL
+ if (conversation.permissions & PARTICIPANT.PERMISSIONS.PUBLISH_AUDIO) {
+ flags |= PARTICIPANT.CALL_FLAG.WITH_AUDIO
+ }
+ if (conversation.permissions & PARTICIPANT.PERMISSIONS.PUBLISH_VIDEO) {
+ flags |= PARTICIPANT.CALL_FLAG.WITH_VIDEO
+ }
+
+ await this.$store.dispatch('joinCall', {
+ token: params.token,
+ participantIdentifier: this.$store.getters.getParticipantIdentifier(),
+ flags,
+ })
+
+ this.$store.dispatch('setForceCallView', false)
+ })
+ }
+
+ this.$router.push({ name: 'conversation', params: { token: params.token, skipLeaveWarning: true } })
+ })
+
EventBus.$on('conversations-received', (params) => {
if (this.$route.name === 'conversation'
&& !this.$store.getters.conversation(this.token)) {
diff --git a/src/mixins/isInCall.js b/src/mixins/isInCall.js
index a5cfa0a0c..d3c6924f0 100644
--- a/src/mixins/isInCall.js
+++ b/src/mixins/isInCall.js
@@ -35,8 +35,9 @@ export default {
computed: {
isInCall() {
- return this.sessionStorageJoinedConversation === this.$store.getters.getToken()
- && this.$store.getters.isInCall(this.$store.getters.getToken())
+ return this.$store.getters.forceCallView
+ || (this.sessionStorageJoinedConversation === this.$store.getters.getToken()
+ && this.$store.getters.isInCall(this.$store.getters.getToken()))
},
},
diff --git a/src/store/callViewStore.js b/src/store/callViewStore.js
index 3fcbec3c3..b5abbc21b 100644
--- a/src/store/callViewStore.js
+++ b/src/store/callViewStore.js
@@ -27,6 +27,7 @@ import {
} from '../constants.js'
const state = {
+ forceCallView: false,
isGrid: false,
isStripeOpen: true,
lastIsGrid: null,
@@ -39,6 +40,7 @@ const state = {
}
const getters = {
+ forceCallView: (state) => state.forceCallView,
isGrid: (state) => state.isGrid,
isStripeOpen: (state) => state.isStripeOpen,
lastIsGrid: (state) => state.lastIsGrid,
@@ -65,6 +67,9 @@ const getters = {
const mutations = {
+ setForceCallView(state, value) {
+ state.forceCallView = value
+ },
isGrid(state, value) {
state.isGrid = value
},
@@ -108,6 +113,10 @@ const mutations = {
}
const actions = {
+ setForceCallView(context, value) {
+ context.commit('setForceCallView', value)
+ },
+
selectedVideoPeerId(context, value) {
context.commit('selectedVideoPeerId', value)
},
diff --git a/src/utils/signaling.js b/src/utils/signaling.js
index ed09af429..ec6d40ba0 100644
--- a/src/utils/signaling.js
+++ b/src/utils/signaling.js
@@ -1275,6 +1275,11 @@ Signaling.Standalone.prototype.processRoomEvent = function(data) {
this._trigger('participantListChanged')
}
break
+ case 'switchto':
+ EventBus.$emit('switch-to-conversation', {
+ token: data.event.switchto.roomid,
+ })
+ break
case 'message':
this.processRoomMessageEvent(data.event.message.data)
break