diff options
Diffstat (limited to 'src/components/MessagesList/MessagesGroup')
3 files changed, 114 insertions, 4 deletions
diff --git a/src/components/MessagesList/MessagesGroup/Message/Message.vue b/src/components/MessagesList/MessagesGroup/Message/Message.vue index 6671b01ad..93065ed19 100644 --- a/src/components/MessagesList/MessagesGroup/Message/Message.vue +++ b/src/components/MessagesList/MessagesGroup/Message/Message.vue @@ -151,6 +151,12 @@ the main body of the message as well as a quote. @click.stop="handleMarkAsUnread"> {{ t('spreed', 'Mark as unread') }} </ActionButton> + <ActionLink + v-if="linkToFile" + icon="icon-text" + :href="linkToFile"> + {{ t('spreed', 'Go to file') }} + </ActionLink> <ActionSeparator v-if="messageActions.length > 0" /> <template v-for="action in messageActions"> @@ -187,6 +193,7 @@ the main body of the message as well as a quote. <script> import ActionButton from '@nextcloud/vue/dist/Components/ActionButton' +import ActionLink from '@nextcloud/vue/dist/Components/ActionLink' import Actions from '@nextcloud/vue/dist/Components/Actions' import ActionSeparator from '@nextcloud/vue/dist/Components/ActionSeparator' import Tooltip from '@nextcloud/vue/dist/Directives/Tooltip' @@ -226,6 +233,7 @@ export default { components: { Actions, ActionButton, + ActionLink, CallButton, Quote, RichText, @@ -562,18 +570,30 @@ export default { && this.actorType === this.$store.getters.getActorType() }, + isFileShare() { + return this.message === '{file}' && this.messageParameters?.file + }, + + linkToFile() { + if (this.isFileShare) { + return this.messageParameters?.file?.link + } + return '' + }, + isDeleteable() { if (this.isConversationReadOnly) { return false } - const isFileShare = this.message === '{file}' - && this.messageParameters?.file + const isObjectShare = this.message === '{object}' + && this.messageParameters?.object return (moment(this.timestamp * 1000).add(6, 'h')) > moment() && this.messageType === 'comment' && !this.isDeleting - && !isFileShare + && !this.isFileShare + && !isObjectShare && (this.isMyMsg || (this.conversation.type !== CONVERSATION.TYPE.ONE_TO_ONE && (this.participant.participantType === PARTICIPANT.TYPE.OWNER diff --git a/src/components/MessagesList/MessagesGroup/Message/MessagePart/AudioPlayer.vue b/src/components/MessagesList/MessagesGroup/Message/MessagePart/AudioPlayer.vue new file mode 100644 index 000000000..64540cf1d --- /dev/null +++ b/src/components/MessagesList/MessagesGroup/Message/MessagePart/AudioPlayer.vue @@ -0,0 +1,82 @@ +<!-- + - @copyright Copyright (c) 2021 Marco Ambrosini <marcoambrosini@pm.me> + - + - @author Marco Ambrosini <marcoambrosini@pm.me> + - + - @license GNU AGPL version 3 or any later version + - + - This program is free software: you can redistribute it and/or modify + - it under the terms of the GNU Affero General Public License as + - published by the Free Software Foundation, either version 3 of the + - License, or (at your option) any later version. + - + - This program is distributed in the hope that it will be useful, + - but WITHOUT ANY WARRANTY; without even the implied warranty of + - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + - GNU Affero General Public License for more details. + - + - You should have received a copy of the GNU Affero General Public License + - along with this program. If not, see <http://www.gnu.org/licenses/>. +--> + +<template> + <div class="wrapper"> + <audio + controls + :src="fileURL"> + {{ t('spreed', 'Your browser does not support playing audio files') }} + </audio> + </div> +</template> + +<script> +import { generateRemoteUrl } from '@nextcloud/router' +import { encodePath } from '@nextcloud/paths' + +export default { + name: 'AudioPlayer', + + props: { + /** + * File name + */ + name: { + type: String, + required: true, + }, + link: { + type: String, + required: true, + }, + /** + * File path relative to the user's home storage, + * or link share root, includes the file name. + */ + path: { + type: String, + required: true, + }, + }, + + computed: { + internalAbsolutePath() { + if (this.path.startsWith('/')) { + return this.path + } + return '/' + this.path + }, + + fileURL() { + const userId = this.$store.getters.getUserId() + if (userId === null) { + // guest mode, use public link download URL + return this.link + '/download/' + encodePath(this.name) + } else { + // use direct DAV URL + return generateRemoteUrl(`dav/files/${userId}`) + encodePath(this.internalAbsolutePath) + } + }, + }, + +} +</script> diff --git a/src/components/MessagesList/MessagesGroup/Message/MessagePart/FilePreview.vue b/src/components/MessagesList/MessagesGroup/Message/MessagePart/FilePreview.vue index b013d62d0..162f1e3b7 100644 --- a/src/components/MessagesList/MessagesGroup/Message/MessagePart/FilePreview.vue +++ b/src/components/MessagesList/MessagesGroup/Message/MessagePart/FilePreview.vue @@ -26,7 +26,7 @@ :tabindex="wrapperTabIndex" class="file-preview" :class="{ 'file-preview--viewer-available': isViewerAvailable, 'file-preview--upload-editor': isUploadEditor }" - @click="handleClick" + @click.exact="handleClick" @keydown.enter="handleClick"> <div v-if="!isLoading" @@ -78,6 +78,7 @@ import Close from 'vue-material-design-icons/Close' import PlayCircleOutline from 'vue-material-design-icons/PlayCircleOutline' import { getCapabilities } from '@nextcloud/capabilities' import { encodePath } from '@nextcloud/paths' +import AudioPlayer from './AudioPlayer' const PREVIEW_TYPE = { TEMPORARY: 0, @@ -236,6 +237,13 @@ export default { is: 'div', tag: 'div', } + } else if (this.mimetype.startsWith('audio')) { + return { + is: AudioPlayer, + name: this.name, + path: this.path, + link: this.link, + } } return { is: 'a', |