From 787308375cc4825a298fee240b6bc60e60792bf1 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Thu, 24 Jun 2021 14:33:16 +0200 Subject: [PATCH] prevent toggling in vm while already busy otherwise the check in SendQueue to prevent duplicates might fail --- .../session/room/timeline/ReactionsViewModel.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/domain/session/room/timeline/ReactionsViewModel.js b/src/domain/session/room/timeline/ReactionsViewModel.js index 50a25529..8813512d 100644 --- a/src/domain/session/room/timeline/ReactionsViewModel.js +++ b/src/domain/session/room/timeline/ReactionsViewModel.js @@ -157,8 +157,17 @@ class ReactionViewModel { } } - toggle(log = null) { - return this._parentTile.toggleReaction(this.key, log); + async toggle(log = null) { + if (this._isToggling) { + console.log("busy toggling reaction already"); + return; + } + this._isToggling = true; + try { + await this._parentTile.toggleReaction(this.key, log); + } finally { + this._isToggling = false; + } } }