Skip to content

Commit

Permalink
fix: show index page instead of hard redirect to 404 on chat delete
Browse files Browse the repository at this point in the history
Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
  • Loading branch information
Antreesy committed Mar 14, 2023
1 parent 4405e14 commit c13a5ed
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/components/LeftSidebar/ConversationsList/Conversation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@

<script>
import { isNavigationFailure, NavigationFailureType } from 'vue-router'
import Cog from 'vue-material-design-icons/Cog.vue'
import Delete from 'vue-material-design-icons/Delete.vue'
import ExitToApp from 'vue-material-design-icons/ExitToApp.vue'
Expand Down Expand Up @@ -295,7 +297,12 @@ export default {
},
to() {
return this.item?.token ? { name: 'conversation', params: { token: this.item.token } } : ''
return this.item?.token
? {
name: 'conversation',
params: { token: this.item.token },
}
: ''
},
isActive() {
Expand Down Expand Up @@ -359,11 +366,14 @@ export default {
try {
await this.$store.dispatch('deleteConversationFromServer', { token: this.item.token })
await this.$store.dispatch('leaveConversation', { token: this.item.token })
await this.$router.push({ name: 'root' })
.catch((failure) => !isNavigationFailure(failure, NavigationFailureType.duplicated) && Promise.reject(failure))
} catch (error) {
console.debug(`error while deleting conversation ${error}`)
showError(t('spreed', 'Error while deleting conversation'))
}
}.bind(this)
}.bind(this),
)
},
Expand All @@ -373,6 +383,8 @@ export default {
async leaveConversation() {
try {
await this.$store.dispatch('removeCurrentUserFromConversation', { token: this.item.token })
await this.$store.dispatch('leaveConversation', { token: this.item.token })
await this.$router.push({ name: 'root' })
} catch (error) {
if (error?.response?.status === 400) {
showError(t('spreed', 'You need to promote a new moderator before you can leave the conversation.'))
Expand All @@ -391,7 +403,10 @@ export default {
* @param {number} level The notification level to set.
*/
async setNotificationLevel(level) {
await this.$store.dispatch('setNotificationLevel', { token: this.item.token, notificationLevel: level })
await this.$store.dispatch('setNotificationLevel', {
token: this.item.token,
notificationLevel: level,
})
},
// forward click event
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ export default {
}
if (from.name === 'conversation') {
this.$store.dispatch('leaveConversation', { token: from.params.token })
if (to.name !== 'conversation') {
this.$store.dispatch('updateToken', '')
}
}
if (to.name === 'conversation') {
this.$store.dispatch('joinConversation', { token: to.params.token })
Expand Down
1 change: 1 addition & 0 deletions src/utils/signaling.js
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ Signaling.Internal.prototype._joinRoomSuccess = function(token, sessionId) {

Signaling.Internal.prototype._doLeaveRoom = function(token) {
this._joinCallAgainOnceDisconnected = false
this.pullMessagesRequest?.('canceled')
}

Signaling.Internal.prototype.sendCallMessage = function(data) {
Expand Down

0 comments on commit c13a5ed

Please sign in to comment.