This commit is contained in:
fmodf 2024-07-01 12:05:39 +02:00
parent 502f6f1cde
commit c0ae9c8c4c
3 changed files with 7 additions and 17 deletions

View file

@ -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)

View file

@ -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()

View file

@ -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("")))
}
}