Skip to content

Commit

Permalink
Handle capabilities and mention editing and change edit timestamp design
Browse files Browse the repository at this point in the history
Signed-off-by: DorraJaouad <dorra.jaoued7@gmail.com>
  • Loading branch information
DorraJaouad committed Jan 26, 2024
1 parent 91c4451 commit de32f0b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,13 @@
{{ messageDateTime }}
</NcActionText>
<!-- Edited message timestamp -->
<NcActionButtonGroup v-if="lastEditTimestamp">
<NcActionText>
<template #icon>
<ClockEditOutline :size="16" />
</template>
{{ lastEditActorDisplayName }}
</NcActionText>
<NcActionText>
{{ editedDateTime }}
</NcActionText>
</NcActionButtonGroup>
<NcActionText v-if="lastEditTimestamp"
:name="lastEditActorDisplayName">
<template #icon>
<ClockEditOutline :size="16" />
</template>
{{ editedDateTime }}
</NcActionText>
<NcActionSeparator />

<NcActionButton v-if="supportReminders"
Expand Down Expand Up @@ -297,7 +293,6 @@ import { showError, showSuccess } from '@nextcloud/dialogs'
import moment from '@nextcloud/moment'

import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js'
import NcActionButtonGroup from '@nextcloud/vue/dist/Components/NcActionButtonGroup.js'
import NcActionInput from '@nextcloud/vue/dist/Components/NcActionInput.js'
import NcActionLink from '@nextcloud/vue/dist/Components/NcActionLink.js'
import NcActions from '@nextcloud/vue/dist/Components/NcActions.js'
Expand All @@ -314,12 +309,13 @@ import { useReactionsStore } from '../../../../../stores/reactions.js'

const EmojiIndex = new EmojiIndexFactory(data)
const supportReminders = getCapabilities()?.spreed?.features?.includes('remind-me-later')
const canEditMessage = getCapabilities()?.spreed?.features?.includes('edit-messages')
const canDeleteMessageUnlimited = getCapabilities()?.spreed?.features?.includes('delete-messages-unlimited')

export default {
name: 'MessageButtonsBar',

components: {
NcActionButtonGroup,
NcActionButton,
NcActionInput,
NcActionLink,
Expand Down Expand Up @@ -518,7 +514,7 @@ export default {
},

isEditable() {
if (!this.isModifiable || this.isObjectShare
if (!canEditMessage || !this.isModifiable || this.isObjectShare
|| (!this.$store.getters.isModerator && !this.isMyMsg)) {
return false
}
Expand All @@ -531,7 +527,8 @@ export default {
return false
}

return (moment(this.timestamp * 1000).add(6, 'h')) > moment()
return ((moment(this.timestamp * 1000).add(6, 'h')) > moment()
|| canDeleteMessageUnlimited)
&& (this.messageType === 'comment' || this.messageType === 'voice-message')
&& !this.isDeleting
&& (this.isMyMsg
Expand Down
12 changes: 12 additions & 0 deletions src/components/NewMessage/NewMessage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@
:can-cancel="!!parentMessage"
:edit-message="!!messageToEdit" />
</div>
<!-- mention editing hint -->
<NcNoteCard v-if="showMentionEditHint" type="warning">
<p>{{ t('spreed','Adding a mention will only notify users who did not read the message.') }}</p>
</NcNoteCard>
<NcRichContenteditable ref="richContenteditable"
v-shortkey.once="$options.disableKeyboardShortcuts ? null : ['c']"
:value.sync="text"
Expand Down Expand Up @@ -194,13 +198,15 @@ import EmoticonOutline from 'vue-material-design-icons/EmoticonOutline.vue'
import Send from 'vue-material-design-icons/Send.vue'

import { getCapabilities } from '@nextcloud/capabilities'
import { showError } from '@nextcloud/dialogs'
import { FilePickerVue } from '@nextcloud/dialogs/filepicker.js'
import { generateOcsUrl } from '@nextcloud/router'

import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js'
import NcActions from '@nextcloud/vue/dist/Components/NcActions.js'
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
import NcEmojiPicker from '@nextcloud/vue/dist/Components/NcEmojiPicker.js'
import NcNoteCard from '@nextcloud/vue/dist/Components/NcNoteCard.js'
import NcRichContenteditable from '@nextcloud/vue/dist/Components/NcRichContenteditable.js'

import NewMessageAbsenceInfo from './NewMessageAbsenceInfo.vue'
Expand Down Expand Up @@ -235,6 +241,7 @@ export default {
NcActions,
NcButton,
NcEmojiPicker,
NcNoteCard,
NcRichContenteditable,
NewMessageAbsenceInfo,
NewMessageAttachments,
Expand Down Expand Up @@ -452,6 +459,10 @@ export default {
chatEditInput() {
return this.chatExtrasStore.getChatEditInput(this.token)
},

showMentionEditHint() {
return this.chatEditInput?.includes('@')
},
},

watch: {
Expand Down Expand Up @@ -689,6 +700,7 @@ export default {
this.chatExtrasStore.removeMessageIdToEdit(this.token)
} catch {
this.$emit('failure')
showError(t('spreed', 'The message could not be edited'))
}
},

Expand Down

0 comments on commit de32f0b

Please sign in to comment.