2020-11-25 14:42:50 +01:00
|
|
|
<template>
|
2020-12-14 16:11:45 +01:00
|
|
|
<div :class="{'message-operations':true,'incoming':incoming,'outgoing':!incoming}">
|
2020-12-03 22:12:50 +01:00
|
|
|
<v-btn icon @click.stop="addReaction" class="ma-0 pa-0">
|
2020-11-25 14:42:50 +01:00
|
|
|
<v-icon>mood</v-icon>
|
|
|
|
|
</v-btn>
|
2020-12-14 16:11:45 +01:00
|
|
|
<v-btn v-if="incoming" icon @click.stop="addReply" class="ma-0 pa-0">
|
|
|
|
|
<v-icon>reply</v-icon>
|
|
|
|
|
</v-btn>
|
|
|
|
|
<v-btn v-if="isEditable" icon @click.stop="edit" class="ma-0 pa-0">
|
|
|
|
|
<v-icon>edit</v-icon>
|
|
|
|
|
</v-btn>
|
2021-02-08 15:31:09 +01:00
|
|
|
<v-btn v-if="isRedactable" icon @click.stop="redact" class="ma-0 pa-0">
|
|
|
|
|
<v-icon>delete</v-icon>
|
|
|
|
|
</v-btn>
|
2021-01-12 09:25:39 +01:00
|
|
|
<v-btn v-if="isDownloadable" icon @click.stop="download" class="ma-0 pa-0">
|
|
|
|
|
<v-icon>get_app</v-icon>
|
|
|
|
|
</v-btn>
|
2020-11-25 14:42:50 +01:00
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import messageMixin from "./messageMixin";
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
mixins: [messageMixin],
|
|
|
|
|
|
|
|
|
|
props: {
|
|
|
|
|
incoming: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
default: function () {
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
event: {
|
|
|
|
|
type: Object,
|
|
|
|
|
default: function () {
|
|
|
|
|
return {}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
},
|
2020-12-03 22:12:50 +01:00
|
|
|
|
2020-12-14 16:11:45 +01:00
|
|
|
computed: {
|
|
|
|
|
isEditable() {
|
|
|
|
|
return !this.incoming && this.event.getContent().msgtype == "m.text";
|
2021-01-12 09:25:39 +01:00
|
|
|
},
|
|
|
|
|
isDownloadable() {
|
|
|
|
|
const msgtype = this.event.getContent().msgtype;
|
|
|
|
|
return ['m.video','m.audio','m.image','m.file'].includes(msgtype);
|
2021-02-08 15:31:09 +01:00
|
|
|
},
|
|
|
|
|
isRedactable() {
|
|
|
|
|
const room = this.$matrix.matrixClient.getRoom(this.event.getRoomId());
|
|
|
|
|
if (room && room.currentState && room.currentState.maySendRedactionForEvent(this.event, this.$matrix.currentUserId)) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
2020-12-14 16:11:45 +01:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2020-11-25 14:42:50 +01:00
|
|
|
methods: {
|
|
|
|
|
addReaction() {
|
2020-12-03 22:12:50 +01:00
|
|
|
this.$emit("close");
|
2020-11-25 14:42:50 +01:00
|
|
|
this.$emit("addreaction", {event:this.event});
|
2020-12-14 16:11:45 +01:00
|
|
|
},
|
|
|
|
|
addReply() {
|
|
|
|
|
this.$emit("close");
|
|
|
|
|
this.$emit("addreply", {event:this.event});
|
|
|
|
|
},
|
|
|
|
|
edit() {
|
|
|
|
|
this.$emit("close");
|
|
|
|
|
this.$emit("edit", {event:this.event});
|
2021-01-12 09:25:39 +01:00
|
|
|
},
|
2021-02-08 15:31:09 +01:00
|
|
|
redact() {
|
|
|
|
|
this.$emit("close");
|
|
|
|
|
this.$emit("redact", {event:this.event});
|
|
|
|
|
},
|
2021-01-12 09:25:39 +01:00
|
|
|
download() {
|
|
|
|
|
this.$emit("close");
|
|
|
|
|
this.$emit("download", {event:this.event});
|
2020-11-25 14:42:50 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
|
@import "@/assets/css/chat.scss";
|
|
|
|
|
</style>
|