Skip to content

Commit

Permalink
Handle "switchto" message in WebUI
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
danxuliu committed Jan 31, 2023
1 parent cee13cb commit 8479b8a
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 3 deletions.
34 changes: 33 additions & 1 deletion src/App.vue
Expand Up @@ -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'
Expand Down Expand Up @@ -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)) {
Expand Down
5 changes: 3 additions & 2 deletions src/mixins/isInCall.js
Expand Up @@ -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()))
},
},

Expand Down
9 changes: 9 additions & 0 deletions src/store/callViewStore.js
Expand Up @@ -27,6 +27,7 @@ import {
} from '../constants.js'

const state = {
forceCallView: false,
isGrid: false,
isStripeOpen: true,
lastIsGrid: null,
Expand All @@ -39,6 +40,7 @@ const state = {
}

const getters = {
forceCallView: (state) => state.forceCallView,
isGrid: (state) => state.isGrid,
isStripeOpen: (state) => state.isStripeOpen,
lastIsGrid: (state) => state.lastIsGrid,
Expand All @@ -65,6 +67,9 @@ const getters = {

const mutations = {

setForceCallView(state, value) {
state.forceCallView = value
},
isGrid(state, value) {
state.isGrid = value
},
Expand Down Expand Up @@ -108,6 +113,10 @@ const mutations = {
}

const actions = {
setForceCallView(context, value) {
context.commit('setForceCallView', value)
},

selectedVideoPeerId(context, value) {
context.commit('selectedVideoPeerId', value)
},
Expand Down
5 changes: 5 additions & 0 deletions src/utils/signaling.js
Expand Up @@ -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
Expand Down

0 comments on commit 8479b8a

Please sign in to comment.