From e1a3e53ae61e389a772eb6a3f131836f6c74e26b Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 24 Jan 2020 10:26:05 +0100 Subject: [PATCH] Require confirmation before deleting a conversation Signed-off-by: Joas Schilling --- css/icons.scss | 8 ++++ .../ConversationsList/Conversation.vue | 38 +++++++++++++++---- 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/css/icons.scss b/css/icons.scss index 34fccc082..b33b9620f 100644 --- a/css/icons.scss +++ b/css/icons.scss @@ -70,6 +70,14 @@ /* Show favorite icon in yellow instead of default black. */ @include icon-color('star-dark', 'actions', 'FC0', 1, true); } + + .icon-delete-critical { + @include icon-color('delete', 'actions', $color-error, 1, true); + &:hover, + &:focus { + filter: initial; + } + } } // The atwho panel is a direct child of the body, so it is not affected by diff --git a/src/components/LeftSidebar/ConversationsList/Conversation.vue b/src/components/LeftSidebar/ConversationsList/Conversation.vue index 49081ce26..1b2593635 100644 --- a/src/components/LeftSidebar/ConversationsList/Conversation.vue +++ b/src/components/LeftSidebar/ConversationsList/Conversation.vue @@ -86,7 +86,8 @@ {{ t('spreed', 'Leave conversation') }} {{ t('spreed', 'Delete conversation') }} @@ -263,13 +264,28 @@ export default { * Deletes the conversation. */ async deleteConversation() { - try { - await deleteConversation(this.item.token) - // If successful, deletes the conversation from the store - this.$store.dispatch('deleteConversation', this.item) - } catch (error) { - console.debug(`error while deleting conversation ${error}`) - } + OC.dialogs.confirm( + t('spreed', 'Do you really want to delete "{displayName}"?', this.item), + t('spreed', 'Delete conversation'), + async function(decision) { + if (!decision) { + return + } + + if (this.item.token === this.$store.getters.getToken()) { + this.$router.push('/apps/spreed') + this.$store.dispatch('updateToken', '') + } + + try { + await deleteConversation(this.item.token) + // If successful, deletes the conversation from the store + this.$store.dispatch('deleteConversation', this.item) + } catch (error) { + console.debug(`error while deleting conversation ${error}`) + } + }.bind(this) + ) }, /** * Deletes the current user from the conversation. @@ -332,6 +348,12 @@ export default { } } +.critical { + ::v-deep .action-button__text { + color: var(--color-error) !important; + } +} + .scroller { flex: 1 0; }