mirror of https://github.com/vector-im/riot-web
Redact existing reaction instead of trying to double-react
Signed-off-by: Tulir Asokan <tulir@maunium.net>pull/21833/head
parent
7fc12b4b13
commit
824685ae64
|
@ -89,19 +89,35 @@ export default class MessageActionBar extends React.PureComponent {
|
||||||
const EmojiPicker = sdk.getComponent('emojipicker.EmojiPicker');
|
const EmojiPicker = sdk.getComponent('emojipicker.EmojiPicker');
|
||||||
const buttonRect = ev.target.getBoundingClientRect();
|
const buttonRect = ev.target.getBoundingClientRect();
|
||||||
|
|
||||||
|
const getReactions = () => {
|
||||||
|
const userId = MatrixClientPeg.get().getUserId();
|
||||||
|
const myAnnotations = this.props.reactions.getAnnotationsBySender()[userId];
|
||||||
|
return Object.fromEntries([...myAnnotations]
|
||||||
|
.filter(event => !event.isRedacted())
|
||||||
|
.map(event => [event.getRelation().key, event.getId()]))
|
||||||
|
};
|
||||||
|
|
||||||
const menuOptions = {
|
const menuOptions = {
|
||||||
reactions: this.props.reactions,
|
reactions: this.props.reactions,
|
||||||
chevronFace: "none",
|
chevronFace: "none",
|
||||||
onFinished: () => this.onFocusChange(false),
|
onFinished: () => this.onFocusChange(false),
|
||||||
onChoose: reaction => {
|
onChoose: reaction => {
|
||||||
this.onFocusChange(false);
|
this.onFocusChange(false);
|
||||||
MatrixClientPeg.get().sendEvent(this.props.mxEvent.getRoomId(), "m.reaction", {
|
const myReactions = getReactions();
|
||||||
"m.relates_to": {
|
if (myReactions.hasOwnProperty(reaction)) {
|
||||||
"rel_type": "m.annotation",
|
MatrixClientPeg.get().redactEvent(
|
||||||
"event_id": this.props.mxEvent.getId(),
|
this.props.mxEvent.getRoomId(),
|
||||||
"key": reaction,
|
myReactions[reaction],
|
||||||
},
|
);
|
||||||
});
|
} else {
|
||||||
|
MatrixClientPeg.get().sendEvent(this.props.mxEvent.getRoomId(), "m.reaction", {
|
||||||
|
"m.relates_to": {
|
||||||
|
"rel_type": "m.annotation",
|
||||||
|
"event_id": this.props.mxEvent.getId(),
|
||||||
|
"key": reaction,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue