diff options
-rw-r--r-- | src/App.vue | 18 | ||||
-rw-r--r-- | src/FilesSidebarCallViewApp.vue | 6 | ||||
-rw-r--r-- | src/FilesSidebarTabApp.vue | 6 | ||||
-rw-r--r-- | src/PublicShareAuthSidebar.vue | 6 | ||||
-rw-r--r-- | src/PublicShareSidebar.vue | 8 | ||||
-rw-r--r-- | src/components/LeftSidebar/ConversationsList/Conversation.vue | 4 | ||||
-rw-r--r-- | src/components/NewMessageForm/AdvancedInput/AdvancedInput.vue | 4 | ||||
-rw-r--r-- | src/mixins/sessionIssueHandler.js (renamed from src/mixins/duplicateSessionHandler.js) | 22 | ||||
-rw-r--r-- | src/utils/signaling.js | 4 |
9 files changed, 47 insertions, 31 deletions
diff --git a/src/App.vue b/src/App.vue index f57543e48..6b26c0b80 100644 --- a/src/App.vue +++ b/src/App.vue @@ -59,7 +59,7 @@ import { } from './utils/webrtc/index' import { emit } from '@nextcloud/event-bus' import browserCheck from './mixins/browserCheck' -import duplicateSessionHandler from './mixins/duplicateSessionHandler' +import sessionIssueHandler from './mixins/sessionIssueHandler' import isInCall from './mixins/isInCall' import participant from './mixins/participant' import talkHashCheck from './mixins/talkHashCheck' @@ -85,7 +85,7 @@ export default { mixins: [ browserCheck, talkHashCheck, - duplicateSessionHandler, + sessionIssueHandler, isInCall, participant, ], @@ -112,7 +112,7 @@ export default { }, warnLeaving() { - return !this.isLeavingAfterSessionConflict && this.isInCall + return !this.isLeavingAfterSessionIssue && this.isInCall }, /** @@ -219,7 +219,7 @@ export default { // We have to do this synchronously, because in unload and beforeunload // Promises, async and await are prohibited. signalingKill() - if (!this.isLeavingAfterSessionConflict) { + if (!this.isLeavingAfterSessionIssue) { leaveConversationSync(this.token) } } @@ -232,8 +232,9 @@ export default { console.info('Conversations received, but the current conversation is not in the list, trying to get potential public conversation manually') this.refreshCurrentConversation() } else { - console.info('Conversation received, but the current conversation is not in the list. Redirecting to /apps/spreed') - this.$router.push('/apps/spreed/not-found') + console.info('Conversation received, but the current conversation is not in the list. Redirecting to not found page') + this.$router.push({ name: 'notfound', params: { skipLeaveWarning: true } }) + this.$store.dispatch('updateToken', '') } } }) @@ -287,7 +288,7 @@ export default { * Global before guard, this is called whenever a navigation is triggered. */ Router.beforeEach((to, from, next) => { - if (this.isInCall) { + if (this.warnLeaving && !to.params?.skipLeaveWarning) { OC.dialogs.confirmDestructive( t('spreed', 'Navigating away from the page will leave the call in {conversation}', { conversation: this.getConversationName(this.token), @@ -437,7 +438,8 @@ export default { }) } catch (exception) { console.info('Conversation received, but the current conversation is not in the list. Redirecting to /apps/spreed') - this.$router.push('/apps/spreed/not-found') + this.$router.push({ name: 'notfound', params: { skipLeaveWarning: true } }) + this.$store.dispatch('updateToken', '') this.$store.dispatch('hideSidebar') } finally { this.isRefreshingCurrentConversation = false diff --git a/src/FilesSidebarCallViewApp.vue b/src/FilesSidebarCallViewApp.vue index 7f5827c1e..cf519dde8 100644 --- a/src/FilesSidebarCallViewApp.vue +++ b/src/FilesSidebarCallViewApp.vue @@ -33,7 +33,7 @@ <script> import CallView from './components/CallView/CallView' import PreventUnload from 'vue-prevent-unload' -import duplicateSessionHandler from './mixins/duplicateSessionHandler' +import sessionIssueHandler from './mixins/sessionIssueHandler' import isInCall from './mixins/isInCall' import participant from './mixins/participant' import talkHashCheck from './mixins/talkHashCheck' @@ -49,7 +49,7 @@ export default { }, mixins: [ - duplicateSessionHandler, + sessionIssueHandler, isInCall, participant, talkHashCheck, @@ -108,7 +108,7 @@ export default { }, warnLeaving() { - return !this.isLeavingAfterSessionConflict && this.showCallView + return !this.isLeavingAfterSessionIssue && this.showCallView }, }, diff --git a/src/FilesSidebarTabApp.vue b/src/FilesSidebarTabApp.vue index 149389d20..bd648ea09 100644 --- a/src/FilesSidebarTabApp.vue +++ b/src/FilesSidebarTabApp.vue @@ -66,7 +66,7 @@ import Axios from '@nextcloud/axios' import UploadEditor from './components/UploadEditor' import CallButton from './components/TopBar/CallButton' import ChatView from './components/ChatView' -import duplicateSessionHandler from './mixins/duplicateSessionHandler' +import sessionIssueHandler from './mixins/sessionIssueHandler' import browserCheck from './mixins/browserCheck' import '@nextcloud/dialogs/styles/toast.scss' @@ -82,7 +82,7 @@ export default { mixins: [ browserCheck, - duplicateSessionHandler, + sessionIssueHandler, ], data() { @@ -164,7 +164,7 @@ export default { // We have to do this synchronously, because in unload and beforeunload // Promises, async and await are prohibited. signalingKill() - if (!this.isLeavingAfterSessionConflict) { + if (!this.isLeavingAfterSessionIssue) { leaveConversationSync(this.token) } } diff --git a/src/PublicShareAuthSidebar.vue b/src/PublicShareAuthSidebar.vue index 7a178971a..09ef4dce5 100644 --- a/src/PublicShareAuthSidebar.vue +++ b/src/PublicShareAuthSidebar.vue @@ -48,7 +48,7 @@ import { leaveConversationSync, } from './services/participantsService' import { signalingKill } from './utils/webrtc/index' -import duplicateSessionHandler from './mixins/duplicateSessionHandler' +import sessionIssueHandler from './mixins/sessionIssueHandler' import talkHashCheck from './mixins/talkHashCheck' export default { @@ -61,7 +61,7 @@ export default { }, mixins: [ - duplicateSessionHandler, + sessionIssueHandler, talkHashCheck, ], @@ -107,7 +107,7 @@ export default { // We have to do this synchronously, because in unload and beforeunload // Promises, async and await are prohibited. signalingKill() - if (!this.isLeavingAfterSessionConflict) { + if (!this.isLeavingAfterSessionIssue) { leaveConversationSync(this.token) } } diff --git a/src/PublicShareSidebar.vue b/src/PublicShareSidebar.vue index 7ec30e1cc..621413a13 100644 --- a/src/PublicShareSidebar.vue +++ b/src/PublicShareSidebar.vue @@ -58,7 +58,7 @@ import { } from './services/participantsService' import { signalingKill } from './utils/webrtc/index' import browserCheck from './mixins/browserCheck' -import duplicateSessionHandler from './mixins/duplicateSessionHandler' +import sessionIssueHandler from './mixins/sessionIssueHandler' import isInCall from './mixins/isInCall' import participant from './mixins/participant' import talkHashCheck from './mixins/talkHashCheck' @@ -77,7 +77,7 @@ export default { mixins: [ browserCheck, - duplicateSessionHandler, + sessionIssueHandler, isInCall, participant, talkHashCheck, @@ -116,7 +116,7 @@ export default { }, warnLeaving() { - return !this.isLeavingAfterSessionConflict && this.isInCall + return !this.isLeavingAfterSessionIssue && this.isInCall }, }, @@ -126,7 +126,7 @@ export default { // We have to do this synchronously, because in unload and beforeunload // Promises, async and await are prohibited. signalingKill() - if (!this.isLeavingAfterSessionConflict) { + if (!this.isLeavingAfterSessionIssue) { leaveConversationSync(this.token) } } diff --git a/src/components/LeftSidebar/ConversationsList/Conversation.vue b/src/components/LeftSidebar/ConversationsList/Conversation.vue index a2f413946..cb58d4ad9 100644 --- a/src/components/LeftSidebar/ConversationsList/Conversation.vue +++ b/src/components/LeftSidebar/ConversationsList/Conversation.vue @@ -84,11 +84,13 @@ <ActionSeparator /> <ActionButton v-if="canLeaveConversation" + :close-after-click="true" :icon="iconLeaveConversation" @click.prevent.exact="leaveConversation"> {{ t('spreed', 'Leave conversation') }} </ActionButton> <ActionButton v-if="canDeleteConversation" + :close-after-click="true" icon="icon-delete-critical" class="critical" @click.prevent.exact="deleteConversation"> @@ -324,7 +326,7 @@ export default { } if (this.item.token === this.$store.getters.getToken()) { - this.$router.push('/apps/spreed') + this.$router.push({ name: 'root', params: { skipLeaveWarning: true } }) this.$store.dispatch('updateToken', '') } diff --git a/src/components/NewMessageForm/AdvancedInput/AdvancedInput.vue b/src/components/NewMessageForm/AdvancedInput/AdvancedInput.vue index 6edf70a1e..e4d05dc06 100644 --- a/src/components/NewMessageForm/AdvancedInput/AdvancedInput.vue +++ b/src/components/NewMessageForm/AdvancedInput/AdvancedInput.vue @@ -256,7 +256,9 @@ export default { // a setTimeout was recommended by the library author here: // https://github.com/fritx/vue-at/issues/114#issuecomment-565777450 setTimeout(() => { - this.$refs.at.closePanel() + if (this.$refs.at) { + this.$refs.at.closePanel() + } }, 100) }, onPaste(e) { diff --git a/src/mixins/duplicateSessionHandler.js b/src/mixins/sessionIssueHandler.js index 604eccb23..7d3c487d6 100644 --- a/src/mixins/duplicateSessionHandler.js +++ b/src/mixins/sessionIssueHandler.js @@ -24,32 +24,42 @@ import { generateUrl } from '@nextcloud/router' import { EventBus } from '../services/EventBus' import SessionStorage from '../services/SessionStorage' -const talkHashCheck = { +const sessionIssueHandler = { data() { return { - isLeavingAfterSessionConflict: false, + isLeavingAfterSessionIssue: false, } }, beforeDestroy() { EventBus.$off('duplicateSessionDetected', this.duplicateSessionTriggered) + EventBus.$off('deletedSessionDetected', this.deletedSessionTriggered) }, beforeMount() { EventBus.$on('duplicateSessionDetected', this.duplicateSessionTriggered) + EventBus.$on('deletedSessionDetected', this.deletedSessionTriggered) }, methods: { duplicateSessionTriggered() { - this.isLeavingAfterSessionConflict = true + this.isLeavingAfterSessionIssue = true SessionStorage.removeItem('joined_conversation') + // Need to delay until next tick, otherwise the PreventUnload is still being triggered + // Putting the window in front with the warning and irritating the user this.$nextTick(() => { - // Need to delay until next tick, otherwise the PreventUnload is still being triggered - // Putting the window in front with the warning and irritating the user + // FIXME: can't use router push as it somehow doesn't clean up + // fully and leads the other instance where "Join here" was clicked + // to redirect to "not found" window.location = generateUrl('/apps/spreed/duplicate-session') }) }, + + deletedSessionTriggered() { + this.$router.push({ name: 'notfound', params: { skipLeaveWarning: true } }) + this.$store.dispatch('updateToken', '') + }, }, } -export default talkHashCheck +export default sessionIssueHandler diff --git a/src/utils/signaling.js b/src/utils/signaling.js index 6042e98de..d65ea53d2 100644 --- a/src/utils/signaling.js +++ b/src/utils/signaling.js @@ -448,7 +448,7 @@ Signaling.Internal.prototype._startPullingMessages = function() { } else if (error.response && (error.response.status === 404 || error.response.status === 403)) { // Conversation was deleted or the user was removed console.error('Conversation was not found anymore') - window.location = generateUrl('/apps/spreed/not-found') + EventBus.$emit('deletedSessionDetected') } else if (token) { if (this.pullMessagesFails === 1) { this.pullMessageErrorToast = showError(t('spreed', 'Lost connection to signaling server. Trying to reconnect.'), { @@ -1130,7 +1130,7 @@ Signaling.Standalone.prototype.processRoomListEvent = function(data) { return } console.error('User or session was removed from the conversation, redirecting') - EventBus.$emit('duplicateSessionDetected') + EventBus.$emit('deletedSessionDetected') break } // eslint-disable-next-line no-fallthrough |