From c2ad9d4f53af77e23c2b8bea09258ba0f647f3af Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Fri, 28 Jun 2019 12:29:03 -0600 Subject: [PATCH] Attach timer finished state once --- src/stores/TypingStore.js | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/stores/TypingStore.js b/src/stores/TypingStore.js index 02778ee4f4..71ae4f55a3 100644 --- a/src/stores/TypingStore.js +++ b/src/stores/TypingStore.js @@ -76,17 +76,21 @@ export default class TypingStore { currentTyping.isTyping = isTyping; if (isTyping) { - currentTyping.serverTimer.restart().finished().then(() => { - const currentTyping = this._typingStates[roomId]; - if (currentTyping) currentTyping.isTyping = false; + if (!currentTyping.serverTimer.isRunning()) { + currentTyping.serverTimer.restart().finished().then(() => { + const currentTyping = this._typingStates[roomId]; + if (currentTyping) currentTyping.isTyping = false; - // The server will (should) time us out on typing, so we don't - // need to advertise a stop of typing. - }); + // The server will (should) time us out on typing, so we don't + // need to advertise a stop of typing. + }); + } else currentTyping.serverTimer.restart(); - currentTyping.userTimer.restart().finished().then(() => { - this.setSelfTyping(roomId, false); - }); + if (!currentTyping.userTimer.isRunning()) { + currentTyping.userTimer.restart().finished().then(() => { + this.setSelfTyping(roomId, false); + }); + } else currentTyping.userTimer.restart(); } MatrixClientPeg.get().sendTyping(roomId, isTyping, TYPING_SERVER_TIMEOUT);