Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/spreed.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormarco <marcoambrosini@pm.me>2022-03-17 16:29:08 +0300
committerJoas Schilling <coding@schilljs.com>2022-03-21 14:08:28 +0300
commite62766fa7083b2ed88231b8cfa4b46dc063c2973 (patch)
tree709d1d3286baccba3f9a975c2fa5a1adee96af5b /src
parenta32ee9262088e9bf241807845b8120e9f3fe7878 (diff)
Move delete method to the message component
Signed-off-by: marco <marcoambrosini@pm.me>
Diffstat (limited to 'src')
-rw-r--r--src/components/MessagesList/MessagesGroup/Message/Message.vue39
-rw-r--r--src/components/MessagesList/MessagesGroup/Message/MessageButtonsBar/MessageButtonsBar.vue40
2 files changed, 41 insertions, 38 deletions
diff --git a/src/components/MessagesList/MessagesGroup/Message/Message.vue b/src/components/MessagesList/MessagesGroup/Message/Message.vue
index 6bd43c33f..7cd2b911e 100644
--- a/src/components/MessagesList/MessagesGroup/Message/Message.vue
+++ b/src/components/MessagesList/MessagesGroup/Message/Message.vue
@@ -153,7 +153,8 @@ the main body of the message as well as a quote.
:message-object="messageObject"
v-bind="$props"
:previous-message-id="previousMessageId"
- :participant="participant" />
+ :participant="participant"
+ @delete="handleDelete" />
<div v-if="isLastReadMessage"
v-observe-visibility="lastReadMessageVisibilityChanged">
<div class="new-message-marker">
@@ -180,7 +181,6 @@ import isInCall from '../../../../mixins/isInCall'
import participant from '../../../../mixins/participant'
import { EventBus } from '../../../../services/EventBus'
import emojiRegex from 'emoji-regex'
-import { CONVERSATION } from '../../../../constants'
import moment from '@nextcloud/moment'
import Location from './MessagePart/Location'
import Contact from './MessagePart/Contact.vue'
@@ -188,6 +188,7 @@ import MessageButtonsBar from './MessageButtonsBar/MessageButtonsBar.vue'
import EmojiPicker from '@nextcloud/vue/dist/Components/EmojiPicker'
import EmoticonOutline from 'vue-material-design-icons/EmoticonOutline.vue'
import Popover from '@nextcloud/vue/dist/Components/Popover'
+import { showError, showSuccess, showWarning, TOAST_DEFAULT_TIMEOUT } from '@nextcloud/dialogs'
export default {
name: 'Message',
@@ -673,6 +674,40 @@ export default {
})
}
},
+
+ async handleDelete() {
+ this.isDeleting = true
+ try {
+ const statusCode = await this.$store.dispatch('deleteMessage', {
+ message: {
+ token: this.token,
+ id: this.id,
+ },
+ placeholder: t('spreed', 'Deleting message'),
+ })
+
+ if (statusCode === 202) {
+ showWarning(t('spreed', 'Message deleted successfully, but Matterbridge is configured and the message might already be distributed to other services'), {
+ timeout: TOAST_DEFAULT_TIMEOUT * 2,
+ })
+ } else if (statusCode === 200) {
+ showSuccess(t('spreed', 'Message deleted successfully'))
+ }
+ } catch (e) {
+ if (e?.response?.status === 400) {
+ showError(t('spreed', 'Message could not be deleted because it is too old'))
+ } else if (e?.response?.status === 405) {
+ showError(t('spreed', 'Only normal chat messages can be deleted'))
+ } else {
+ showError(t('spreed', 'An error occurred while deleting the message'))
+ console.error(e)
+ }
+ this.isDeleting = false
+ return
+ }
+
+ this.isDeleting = false
+ },
},
}
</script>
diff --git a/src/components/MessagesList/MessagesGroup/Message/MessageButtonsBar/MessageButtonsBar.vue b/src/components/MessagesList/MessagesGroup/Message/MessageButtonsBar/MessageButtonsBar.vue
index 4ab7304e7..d1dc56aeb 100644
--- a/src/components/MessagesList/MessagesGroup/Message/MessageButtonsBar/MessageButtonsBar.vue
+++ b/src/components/MessagesList/MessagesGroup/Message/MessageButtonsBar/MessageButtonsBar.vue
@@ -142,8 +142,6 @@ import { generateUrl } from '@nextcloud/router'
import {
showError,
showSuccess,
- showWarning,
- TOAST_DEFAULT_TIMEOUT,
} from '@nextcloud/dialogs'
import Forwarder from '../MessagePart/Forwarder'
import Button from '@nextcloud/vue/dist/Components/Button'
@@ -374,40 +372,6 @@ export default {
EventBus.$emit('focus-chat-input')
},
- async handleDelete() {
- this.isDeleting = true
- try {
- const statusCode = await this.$store.dispatch('deleteMessage', {
- message: {
- token: this.token,
- id: this.id,
- },
- placeholder: t('spreed', 'Deleting message'),
- })
-
- if (statusCode === 202) {
- showWarning(t('spreed', 'Message deleted successfully, but Matterbridge is configured and the message might already be distributed to other services'), {
- timeout: TOAST_DEFAULT_TIMEOUT * 2,
- })
- } else if (statusCode === 200) {
- showSuccess(t('spreed', 'Message deleted successfully'))
- }
- } catch (e) {
- if (e?.response?.status === 400) {
- showError(t('spreed', 'Message could not be deleted because it is too old'))
- } else if (e?.response?.status === 405) {
- showError(t('spreed', 'Only normal chat messages can be deleted'))
- } else {
- showError(t('spreed', 'An error occurred while deleting the message'))
- console.error(e)
- }
- this.isDeleting = false
- return
- }
-
- this.isDeleting = false
- },
-
handleActionMenuUpdate(type) {
if (type === 'open') {
this.isActionMenuOpen = true
@@ -460,6 +424,10 @@ export default {
}
},
+
+ handleDelete() {
+ this.$emit('delete')
+ },
},
}
</script>