diff --git a/src/assets/css/chat.scss b/src/assets/css/chat.scss index 8d7132a..5781f12 100644 --- a/src/assets/css/chat.scss +++ b/src/assets/css/chat.scss @@ -1531,4 +1531,18 @@ body { right: 20px; bottom: 20px; position: absolute; +} + +.download-all-button { + font-family: "Inter", sans-serif; + font-weight: 700; + font-size: 11.54 * $chat-text-size; + line-height: 140%; + color: white !important; + background-color: #4642f1 !important; + border-radius: $small-button-height / 2; + min-height: 0; + height: $small-button-height !important; + margin-top: $chat-standard-padding-xs; + margin-bottom: $chat-standard-padding-xs; } \ No newline at end of file diff --git a/src/assets/translations/en.json b/src/assets/translations/en.json index cd12ab2..fea61ac 100644 --- a/src/assets/translations/en.json +++ b/src/assets/translations/en.json @@ -104,7 +104,8 @@ "file": "File", "files": "Files", "images": "Images", - "send_attachements_dialog_title": "Do you want to send following attachments ?" + "send_attachements_dialog_title": "Do you want to send following attachments ?", + "download_all": "Download all" }, "room": { "invitations": "You have no invitations | You have 1 invitation | You have {count} invitations", diff --git a/src/components/Chat.vue b/src/components/Chat.vue index 7cbb7c3..7b8f8dc 100644 --- a/src/components/Chat.vue +++ b/src/components/Chat.vue @@ -1419,24 +1419,7 @@ export default { }, download(event) { - util - .getAttachment(this.$matrix.matrixClient, event) - .then((url) => { - const link = document.createElement("a"); - link.href = url; - link.target = "_blank"; - link.download = event.getContent().body || this.$t("fallbacks.download_name"); - document.body.appendChild(link); - link.click(); - - setTimeout(function () { - document.body.removeChild(link); - URL.revokeObjectURL(url); - }, 200); - }) - .catch((err) => { - console.log("Failed to fetch attachment: ", err); - }); + util.download(this.$matrix.matrixClient, event); }, cancelEditReply() { diff --git a/src/components/messages/MessageIncomingThread.vue b/src/components/messages/MessageIncomingThread.vue index 0ff7129..89b4ecb 100644 --- a/src/components/messages/MessageIncomingThread.vue +++ b/src/components/messages/MessageIncomingThread.vue @@ -5,10 +5,14 @@ - + +
+ {{ $t("message.download_all") }} arrow_downward +
block {{ $t('message.incoming_message_deleted_text') }} @@ -19,6 +23,9 @@ + + + @@ -33,28 +40,55 @@ export default { mixins: [messageMixin], data() { return { - items: [] + items: [], + dialog: false, + dialogSrc: null, + thread: null, } }, mounted() { - this.items = this.timelineSet.relations.getAllChildEventsForEvent(this.event.getId()).map(e => { - let ret = { - event: e, - src: null, - }; - ret.promise = - util - .getThumbnail(this.$matrix.matrixClient, e, 100, 100) - .then((url) => { - ret.src = url; - }) - .catch((err) => { - console.log("Failed to fetch thumbnail: ", err); - }); - return ret; - }) + this.thread = this.timelineSet.relations.getChildEventsForEvent(this.event.getId(), "m.thread", "m.room.message"); + this.processThread(); + }, + beforeDestroy() { + this.thread = null; + }, + watch: { + thread: { + handler(newValue, oldValue) { + if (oldValue) { + oldValue.off('Relations.add', this.onAddRelation); + } + if (newValue) { + newValue.on('Relations.add', this.onAddRelation); + } + this.processThread(); + }, + immediate: true + } }, methods: { + onAddRelation() { + this.processThread(); + }, + processThread() { + this.items = this.timelineSet.relations.getAllChildEventsForEvent(this.event.getId()).map(e => { + let ret = { + event: e, + src: null, + }; + ret.promise = + util + .getThumbnail(this.$matrix.matrixClient, e, 100, 100) + .then((url) => { + ret.src = url; + }) + .catch((err) => { + console.log("Failed to fetch thumbnail: ", err); + }); + return ret; + }); + }, layoutedItems() { if (!this.items || this.items.length == 0) { return [] } let array = this.items.slice(0); @@ -84,6 +118,9 @@ export default { } } return rows + }, + downloadAll() { + this.items.forEach(item => util.download(this.$matrix.matrixClient, item.event)); } } }; @@ -94,7 +131,6 @@ export default {