From 527f1b6b5b7d29d244018e3132be4d61efc5b986 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 16 Jan 2020 19:40:21 +0100 Subject: [PATCH] Confirm leaving the call Signed-off-by: Joas Schilling --- src/App.vue | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/src/App.vue b/src/App.vue index c27ce4a9e..b469fc2fb 100644 --- a/src/App.vue +++ b/src/App.vue @@ -225,17 +225,14 @@ export default { } }) - /** - * Global before guard, this is called whenever a navigation is triggered. - */ - Router.beforeEach((to, from, next) => { + const beforeRouteChangeListener = (to, from, next) => { /** * This runs whenever the new route is a conversation. */ if (to.name === 'conversation') { // Page title - const NEXT_CONVERSATION_NAME = this.getConversationName(to.params.token) - this.setPageTitle(NEXT_CONVERSATION_NAME) + const nextConversationName = this.getConversationName(to.params.token) + this.setPageTitle(nextConversationName) // Update current token in the token store this.$store.dispatch('updateToken', to.params.token) } @@ -246,6 +243,27 @@ export default { EventBus.$emit('routeChange', { from, to }) next() + } + + /** + * Global before guard, this is called whenever a navigation is triggered. + */ + Router.beforeEach((to, from, next) => { + if (this.isInCall) { + OC.dialogs.confirm( + t('spreed', 'Do you really want to leave the call?'), + t('spreed', 'Leaving call'), + (decision) => { + if (!decision) { + return + } + + beforeRouteChangeListener(to, from, next) + } + ) + } else { + beforeRouteChangeListener(to, from, next) + } }) if (getCurrentUser()) {