mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Fix scroll to bottom when a new message is received
This commit is contained in:
parent
19a14496a2
commit
b5b6fead55
1 changed files with 6 additions and 4 deletions
|
|
@ -316,14 +316,16 @@ struct UserMessageList: View {
|
|||
scrollView.scrollTo(allMessages.firstIndex(of: allMessages.last! ), anchor: .bottom)
|
||||
}
|
||||
})
|
||||
.onChange(of: user, perform: { newValue in
|
||||
.onChange(of: allMessages.count, perform: { count in
|
||||
|
||||
self.context.refresh(user, mergeChanges: true)
|
||||
messageCount = ((user.sentMessages?.count ?? 0) + (user.receivedMessages?.count ?? 0))
|
||||
|
||||
if messageCount > 0 {
|
||||
let index = count - 1
|
||||
|
||||
if index > 2 {
|
||||
|
||||
scrollView.scrollTo(index, anchor: .bottom)
|
||||
|
||||
scrollView.scrollTo(allMessages.firstIndex(of: allMessages.last! ), anchor: .bottom)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue