Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(chat): add download link to attachments #13618

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,21 @@
</template>
{{ t('spreed', 'Mark as unread') }}
</NcActionButton>
<NcActionLink v-if="linkToFile"
:href="linkToFile">
<template #icon>
<File :size="20" />
</template>
{{ t('spreed', 'Go to file') }}
</NcActionLink>
<template v-if="isFileShare">
<NcActionSeparator />
<NcActionLink :href="linkToFile">
<template #icon>
<File :size="20" />
</template>
{{ t('spreed', 'Go to file') }}
</NcActionLink>
Comment on lines +111 to +116
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wasn't supposed to be shown for guests, no 🤔 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is wasn't shown, but I don't think it wasn't supposed to. It was a bug.

There was no link in the menu, but the preview itself is a link anyway.

Copy link
Contributor

@Antreesy Antreesy Oct 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shared files in public rooms are public shares, so should be correct here to have access for guests:

  • as user: https://nextcloud.local/index.php/f/585
  • as guest: https://nextcloud.local/index.php/s/A4ERJc3xMKmN88o

<NcActionLink :href="linkToFileDownload" :download="messageFile.name">
<template #icon>
<IconDownload :size="20" />
</template>
{{ t('spreed', 'Download file') }}
</NcActionLink>
</template>
<NcActionButton v-if="canForwardMessage && !isInNoteToSelf"
close-after-click
@click="forwardToNote">
Expand Down Expand Up @@ -260,6 +268,7 @@ import ClockOutline from 'vue-material-design-icons/ClockOutline.vue'
import CloseCircleOutline from 'vue-material-design-icons/CloseCircleOutline.vue'
import ContentCopy from 'vue-material-design-icons/ContentCopy.vue'
import DeleteIcon from 'vue-material-design-icons/Delete.vue'
import IconDownload from 'vue-material-design-icons/Download.vue'
import EmoticonOutline from 'vue-material-design-icons/EmoticonOutline.vue'
import EyeOffOutline from 'vue-material-design-icons/EyeOffOutline.vue'
import File from 'vue-material-design-icons/File.vue'
Expand All @@ -271,7 +280,9 @@ import Reply from 'vue-material-design-icons/Reply.vue'
import Share from 'vue-material-design-icons/Share.vue'
import Translate from 'vue-material-design-icons/Translate.vue'
import { getCurrentUser } from '@nextcloud/auth'
import { showError, showSuccess } from '@nextcloud/dialogs'
import { davRemoteURL } from '@nextcloud/files'
import { t } from '@nextcloud/l10n'
import moment from '@nextcloud/moment'
Expand Down Expand Up @@ -317,6 +328,7 @@ export default {
ClockEditOutline,
ClockOutline,
ContentCopy,
IconDownload,
DeleteIcon,
EmoticonOutline,
EyeOffOutline,
Expand Down Expand Up @@ -438,13 +450,22 @@ export default {
&& this.$store.getters.isActorUser()
},
messageFile() {
const firstFileKey = (Object.keys(this.message.messageParameters).find(key => key.startsWith('file')))
return this.message.messageParameters[firstFileKey]
},
linkToFile() {
if (this.isFileShare) {
const firstFileKey = (Object.keys(this.message.messageParameters).find(key => key.startsWith('file')))
return this.message.messageParameters?.[firstFileKey]?.link
} else {
return ''
return this.messageFile.link
},
linkToFileDownload() {
const uid = getCurrentUser()?.uid
if (!uid) {
const fileid = this.linkToFile.slice(this.linkToFile.lastIndexOf('/') + 1)
return this.messageFile.link + '/download/' + encodeURI(fileid)
}
return davRemoteURL + '/files/' + encodeURI(uid) + '/' + encodeURI(this.messageFile.path)
Comment on lines +463 to +468
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we'll move it to utils/fileDownload.ts? Feels like a fit to keep reusable logic there

},
isCurrentGuest() {
Expand Down
Loading