When sending reaction, redact if already send
This commit is contained in:
parent
7c0af3fb2d
commit
7ac777d971
3 changed files with 46 additions and 6 deletions
|
|
@ -55,7 +55,7 @@
|
|||
}
|
||||
" v-on:touchend="touchEnd" v-on:touchcancel="touchCancel" v-on:touchmove="touchMove">
|
||||
<component :is="componentForEvent(event)" :room="room" :originalEvent="event" :nextEvent="events[index + 1]"
|
||||
:timelineSet="timelineSet" v-on:send-quick-reaction="sendQuickReaction"
|
||||
:timelineSet="timelineSet" v-on:send-quick-reaction.stop="sendQuickReaction"
|
||||
v-on:context-menu="showContextMenuForEvent($event)" v-on:own-avatar-clicked="viewProfile"
|
||||
v-on:other-avatar-clicked="showAvatarMenuForEvent($event)" v-on:download="download(event)"
|
||||
v-on:poll-closed="pollWasClosed(event)" />
|
||||
|
|
@ -510,7 +510,7 @@ export default {
|
|||
return util.browserCanRecordAudio();
|
||||
},
|
||||
debugging() {
|
||||
return (window.location.host || "").startsWith("localhost");
|
||||
return false; //(window.location.host || "").startsWith("localhost");
|
||||
},
|
||||
invitationCount() {
|
||||
return this.$matrix.invites.length;
|
||||
|
|
@ -1202,6 +1202,24 @@ export default {
|
|||
},
|
||||
|
||||
sendQuickReaction(e) {
|
||||
let previousReaction = null;
|
||||
|
||||
// Figure out if we have already sent this emoji, in that case redact it again (toggle)
|
||||
//
|
||||
const reactions = this.timelineSet.relations.getChildEventsForEvent(e.event.getId(), 'm.annotation', 'm.reaction');
|
||||
if (reactions && reactions._eventsCount > 0) {
|
||||
const relations = reactions.getRelations();
|
||||
for (const r of relations) {
|
||||
const emoji = r.getRelation().key;
|
||||
const sender = r.getSender();
|
||||
if (emoji == e.reaction && sender == this.$matrix.currentUserId) {
|
||||
previousReaction = r.isRedacted() ? null : r;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (previousReaction) {
|
||||
this.redact(previousReaction);
|
||||
} else {
|
||||
util
|
||||
.sendQuickReaction(this.$matrix.matrixClient, this.roomId, e.reaction, e.event)
|
||||
.then(() => {
|
||||
|
|
@ -1210,6 +1228,7 @@ export default {
|
|||
.catch((err) => {
|
||||
console.log("Failed to send quick reaction:", err);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
sendSticker(stickerShortCode) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue