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