From 20abb01ee8f2e2ec56a2b172c3b4418b31fc9faf Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Thu, 3 Jun 2021 19:16:53 +0200 Subject: [PATCH] very basic way of sending a reaction --- src/domain/session/room/timeline/tiles/BaseMessageTile.js | 4 ++++ src/matrix/room/timeline/entries/BaseEventEntry.js | 7 ++++++- .../web/ui/session/room/timeline/BaseMessageView.js | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/domain/session/room/timeline/tiles/BaseMessageTile.js b/src/domain/session/room/timeline/tiles/BaseMessageTile.js index b03e2fee..f480f0db 100644 --- a/src/domain/session/room/timeline/tiles/BaseMessageTile.js +++ b/src/domain/session/room/timeline/tiles/BaseMessageTile.js @@ -122,6 +122,10 @@ export class BaseMessageTile extends SimpleTile { return this._reactions; } + react(key) { + this._room.sendEvent("m.reaction", this._entry.annotate(key)); + } + _updateReactions() { const {annotations} = this._entry; if (!annotations) { diff --git a/src/matrix/room/timeline/entries/BaseEventEntry.js b/src/matrix/room/timeline/entries/BaseEventEntry.js index 4bf09ed5..a036e8c6 100644 --- a/src/matrix/room/timeline/entries/BaseEventEntry.js +++ b/src/matrix/room/timeline/entries/BaseEventEntry.js @@ -16,6 +16,7 @@ limitations under the License. import {BaseEntry} from "./BaseEntry.js"; import {REDACTION_TYPE} from "../../common.js"; +import {createAnnotation} from "../relations.js"; export class BaseEventEntry extends BaseEntry { constructor(fragmentIdComparer) { @@ -80,4 +81,8 @@ export class BaseEventEntry extends BaseEntry { // so don't clear _pendingRedactions here } } -} \ No newline at end of file + + annotate(key) { + return createAnnotation(this.id, key); + } +} diff --git a/src/platform/web/ui/session/room/timeline/BaseMessageView.js b/src/platform/web/ui/session/room/timeline/BaseMessageView.js index 0c9c0c0e..2f41fa75 100644 --- a/src/platform/web/ui/session/room/timeline/BaseMessageView.js +++ b/src/platform/web/ui/session/room/timeline/BaseMessageView.js @@ -99,6 +99,7 @@ export class BaseMessageView extends TemplateView { } else if (vm.canRedact) { options.push(Menu.option(vm.i18n`Delete`, () => vm.redact()).setDestructive()); } + options.push(Menu.option(vm.i18n`React with 👍`, () => vm.react("👍"))) return options; }