wip
This commit is contained in:
parent
502f6f1cde
commit
c0ae9c8c4c
|
@ -278,7 +278,7 @@ private extension DatabaseMiddleware {
|
|||
Column("to") == chat.account ||
|
||||
(Column("from") == chat.account && Column("to") == chat.participant)
|
||||
)
|
||||
.order(Column("date").asc)
|
||||
.order(Column("date").desc)
|
||||
.fetchAll
|
||||
)
|
||||
.publisher(in: database._db, scheduling: .immediate)
|
||||
|
|
|
@ -28,40 +28,30 @@ struct ConversationScreen: View {
|
|||
ConversationMessageRow(message: message)
|
||||
.id(message.id)
|
||||
.onAppear {
|
||||
if message.id == messages.last?.id {
|
||||
if message.id == messages.first?.id {
|
||||
autoScroll = true
|
||||
}
|
||||
}
|
||||
.onDisappear {
|
||||
if message.id == messages.last?.id {
|
||||
if message.id == messages.first?.id {
|
||||
autoScroll = false
|
||||
}
|
||||
}
|
||||
}
|
||||
.rotationEffect(.degrees(180))
|
||||
}
|
||||
.rotationEffect(.degrees(180))
|
||||
.listStyle(.plain)
|
||||
.background(Color.Main.backgroundLight)
|
||||
.scrollDismissesKeyboard(.immediately)
|
||||
.scrollIndicators(.hidden)
|
||||
.onChange(of: messages) { _ in
|
||||
if autoScroll {
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
||||
withAnimation {
|
||||
proxy.scrollTo(messages.last?.id, anchor: .bottom)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.onChange(of: autoScroll) { new in
|
||||
if new {
|
||||
withAnimation {
|
||||
proxy.scrollTo(messages.last?.id, anchor: .bottom)
|
||||
proxy.scrollTo(messages.first?.id, anchor: .top)
|
||||
}
|
||||
}
|
||||
}
|
||||
.onAppear {
|
||||
proxy.scrollTo(messages.last?.id, anchor: .bottom)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Spacer()
|
||||
|
|
|
@ -73,7 +73,7 @@ struct ConversationTextInput: View {
|
|||
body: composedMessage
|
||||
)))
|
||||
messageStr = ""
|
||||
UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)
|
||||
// UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)
|
||||
store.dispatch(.conversationAction(.setReplyText("")))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue