file types and exports

This commit is contained in:
N-Pex 2023-12-04 11:29:23 +01:00
parent db04080463
commit 324ccd70b3
21 changed files with 339 additions and 55 deletions

View file

@ -4,7 +4,8 @@ export default {
data() {
return {
src: null,
downloadProgress: null
downloadProgress: null,
userInitiatedDownloadsOnly: false,
}
},
watch: {
@ -21,14 +22,27 @@ export default {
beforeDestroy() {
this.loadAttachmentSource(null); // Release
},
computed: {
fileName() {
return util.getFileName(this.event);
},
fileSize() {
return util.getFileSizeFormatted(this.event);
}
},
methods: {
loadAttachmentSource(event) {
loadAttachmentSource(event, userInitiated = false) {
if (this.src) {
const objectUrl = this.src;
this.src = null;
URL.revokeObjectURL(objectUrl);
}
if (event) {
const fileSize = util.getFileSize(event);
if (!userInitiated && (fileSize == 0 || fileSize > 1000000)) {
this.userInitiatedDownloadsOnly = true;
return;
}
util
.getAttachment(this.$matrix.matrixClient, event, (progress) => {
this.downloadProgress = progress;