Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable24] Fix leaving call when switching to another conversation #8530

Merged
merged 2 commits into from Jan 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/FilesSidebarTabApp.vue
Expand Up @@ -185,6 +185,15 @@ export default {
return
}

// TODO: move to store under a special action ?

// Remove the conversation to ensure that the old data is not used
// before fetching it again if this conversation is joined again.
await this.$store.dispatch('deleteConversation', this.token)
// Remove the participant to ensure that it will be set again fresh
// if this conversation is joined again.
await this.$store.dispatch('purgeParticipantsStore', this.token)

await this.$store.dispatch('joinConversation', { token: this.token })

// The current participant (which is automatically set when fetching
Expand Down Expand Up @@ -219,15 +228,6 @@ export default {
EventBus.$off('signaling-participant-list-changed', OCA.Talk.fetchCurrentConversationWrapper)
window.clearInterval(OCA.Talk.fetchCurrentConversationIntervalId)

// TODO: move to store under a special action ?

// Remove the conversation to ensure that the old data is not used
// before fetching it again if this conversation is joined again.
this.$store.dispatch('deleteConversation', this.token)
// Remove the participant to ensure that it will be set again fresh
// if this conversation is joined again.
this.$store.dispatch('purgeParticipantsStore', this.token)

this.$store.dispatch('leaveConversation', { token: this.token })

this.$store.dispatch('updateTokenAndFileIdForToken', {
Expand Down
7 changes: 7 additions & 0 deletions src/store/participantsStore.js
Expand Up @@ -533,6 +533,13 @@ const actions = {
* @param {string} data.token - conversation token.
*/
async leaveConversation(context, { token }) {
if (context.getters.isInCall(token)) {
await context.dispatch('leaveCall', {
token,
participantIdentifier: context.getters.getParticipantIdentifier(),
})
}

await leaveConversation(token)
},

Expand Down
40 changes: 40 additions & 0 deletions src/store/participantsStore.spec.js
Expand Up @@ -685,6 +685,46 @@ describe('participantsStore', () => {

await store.dispatch('leaveConversation', { token: TOKEN })

expect(leaveCall).not.toHaveBeenCalled()
expect(leaveConversation).toHaveBeenCalledWith(TOKEN)
})

test('leaves conversation while in call', async () => {
testStoreConfig.getters.getParticipantIdentifier = () => jest.fn().mockReturnValue({
attendeeId: 1,
sessionId: 'session-id-1',
})
store = new Vuex.Store(testStoreConfig)

store.dispatch('addParticipant', {
token: TOKEN,
participant: {
attendeeId: 1,
sessionId: 'session-id-1',
participantType: PARTICIPANT.TYPE.USER,
inCall: PARTICIPANT.CALL_FLAG.DISCONNECTED,
},
})

const flags = PARTICIPANT.CALL_FLAG.WITH_AUDIO | PARTICIPANT.CALL_FLAG.WITH_VIDEO
await store.dispatch('joinCall', {
token: TOKEN,
participantIdentifier: {
attendeeId: 1,
sessionId: 'session-id-1',
},
flags,
silent: false,
})

expect(store.getters.isInCall(TOKEN)).toBe(true)

leaveConversation.mockResolvedValue()

await store.dispatch('leaveConversation', { token: TOKEN })

expect(store.getters.isInCall(TOKEN)).toBe(false)
expect(leaveCall).toHaveBeenCalledWith(TOKEN, false)
expect(leaveConversation).toHaveBeenCalledWith(TOKEN)
})

Expand Down