diff options
author | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2020-01-15 19:17:41 +0300 |
---|---|---|
committer | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2020-01-16 20:33:39 +0300 |
commit | 1efe60980e5268418ec9a95e1d96492c2ba5fc89 (patch) | |
tree | 52e35f1f9c17aeae128ed51cd7a4274aab464bba /src/PublicShareSidebar.vue | |
parent | ddb0c36ccd0603833551a55995b06689fdf7bf56 (diff) |
Leave conversation when navigating away from public share page
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'src/PublicShareSidebar.vue')
-rw-r--r-- | src/PublicShareSidebar.vue | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/PublicShareSidebar.vue b/src/PublicShareSidebar.vue index 1120aff34..6cf714a93 100644 --- a/src/PublicShareSidebar.vue +++ b/src/PublicShareSidebar.vue @@ -48,8 +48,14 @@ import { PARTICIPANT } from './constants' import { EventBus } from './services/EventBus' import { fetchConversation } from './services/conversationsService' import { getPublicShareConversationData } from './services/filesIntegrationServices' -import { joinConversation } from './services/participantsService' -import { getSignaling } from './utils/webrtc/index' +import { + joinConversation, + leaveConversationSync, +} from './services/participantsService' +import { + getSignaling, + getSignalingSync, +} from './utils/webrtc/index' export default { @@ -106,6 +112,20 @@ export default { }, }, + beforeMount() { + window.addEventListener('unload', () => { + if (this.token) { + // We have to do this synchronously, because in unload and beforeunload + // Promises, async and await are prohibited. + const signaling = getSignalingSync() + if (signaling) { + signaling.disconnect() + } + leaveConversationSync(this.token) + } + }) + }, + methods: { async joinConversation() { |