|
|
|
@ -7,6 +7,7 @@ struct ConversationView : View {
|
|
|
|
|
var messages: [Message] |
|
|
|
|
|
|
|
|
|
var body: some View { |
|
|
|
|
ScrollViewReader { proxy in |
|
|
|
|
ScrollView { |
|
|
|
|
LazyVStack { |
|
|
|
|
ForEach(messages) { message in |
|
|
|
@ -14,12 +15,18 @@ struct ConversationView : View {
|
|
|
|
|
Spacer() |
|
|
|
|
} |
|
|
|
|
MessageView(message: message) |
|
|
|
|
.id(message) |
|
|
|
|
if !message.sentByMe { |
|
|
|
|
Spacer() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
.navigationTitle(conversation.effectiveDisplayName) |
|
|
|
|
.onChange(of: messages) { newValue in |
|
|
|
|
proxy.scrollTo(newValue.last, anchor: .bottom) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -29,6 +36,7 @@ struct ConversationViewWrapper : View {
|
|
|
|
|
@EnvironmentObject private var connection: Connection |
|
|
|
|
|
|
|
|
|
private func refresh() { |
|
|
|
|
messages.removeAll() |
|
|
|
|
Task { |
|
|
|
|
self.messages = await connection.messages(in: conversation) ?? .init() |
|
|
|
|
} |
|
|
|
|