|
|
@ -7,6 +7,7 @@ struct ConversationView : View { |
|
|
|
var messages: [Message] |
|
|
|
var messages: [Message] |
|
|
|
|
|
|
|
|
|
|
|
var body: some View { |
|
|
|
var body: some View { |
|
|
|
|
|
|
|
ScrollViewReader { proxy in |
|
|
|
ScrollView { |
|
|
|
ScrollView { |
|
|
|
LazyVStack { |
|
|
|
LazyVStack { |
|
|
|
ForEach(messages) { message in |
|
|
|
ForEach(messages) { message in |
|
|
@ -14,12 +15,18 @@ struct ConversationView : View { |
|
|
|
Spacer() |
|
|
|
Spacer() |
|
|
|
} |
|
|
|
} |
|
|
|
MessageView(message: message) |
|
|
|
MessageView(message: message) |
|
|
|
|
|
|
|
.id(message) |
|
|
|
if !message.sentByMe { |
|
|
|
if !message.sentByMe { |
|
|
|
Spacer() |
|
|
|
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 |
|
|
|
@EnvironmentObject private var connection: Connection |
|
|
|
|
|
|
|
|
|
|
|
private func refresh() { |
|
|
|
private func refresh() { |
|
|
|
|
|
|
|
messages.removeAll() |
|
|
|
Task { |
|
|
|
Task { |
|
|
|
self.messages = await connection.messages(in: conversation) ?? .init() |
|
|
|
self.messages = await connection.messages(in: conversation) ?? .init() |
|
|
|
} |
|
|
|
} |
|
|
|