Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(chat): fix typing indicator #961

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/lib/state/ui/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)))

Expand All @@ -185,7 +184,6 @@ class Store {
}
return c
})
chat.typing_indicator.update()
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/lib/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
}

Expand Down
Loading