diff --git a/src/lib/state/ui/index.ts b/src/lib/state/ui/index.ts index aaf0b463e..f739a271a 100644 --- a/src/lib/state/ui/index.ts +++ b/src/lib/state/ui/index.ts @@ -171,8 +171,7 @@ class Store { } updateTypingIndicators(chat: Chat) { - let update = chat.typing_indicator.size !== 0 - chat.typing_indicator.update() + let update = chat.typing_indicator.update() if (update) { this.state.chats.update(chats => chats.map(c => (c.id === chat.id ? { ...c, typing_indicator: chat.typing_indicator } : c))) @@ -185,7 +184,6 @@ class Store { } return c }) - chat.typing_indicator.update() } } diff --git a/src/lib/types/index.ts b/src/lib/types/index.ts index 59a3de59c..124db3472 100644 --- a/src/lib/types/index.ts +++ b/src/lib/types/index.ts @@ -233,6 +233,7 @@ export class TypingIndicator { * @returns True if something changed */ update(): boolean { + if (this.size === 0) return false let time = new Date() time.setSeconds(time.getSeconds() - 5) let it = Object.entries(this.typingIndicator) @@ -242,7 +243,7 @@ export class TypingIndicator { obj[id] = date return obj }, {}) - this._size = updated.length > 0 ? 1 : 0 + this._size = updated.length return old_len != this._size }