ios: better fix for scroll
This commit is contained in:
@@ -5,6 +5,7 @@ struct SybilChatTranscriptView: View {
|
||||
var messages: [Message]
|
||||
var isLoading: Bool
|
||||
var isSending: Bool
|
||||
@State private var hasHandledInitialTranscriptScroll = false
|
||||
|
||||
private var hasPendingAssistant: Bool {
|
||||
messages.contains { message in
|
||||
@@ -55,10 +56,11 @@ struct SybilChatTranscriptView: View {
|
||||
scrollToBottom(with: proxy, animated: false)
|
||||
}
|
||||
.onChange(of: messages.map(\.id)) { _, _ in
|
||||
scrollToBottom(with: proxy, animated: !isLoading)
|
||||
scrollToBottom(with: proxy, animated: hasHandledInitialTranscriptScroll && !isLoading)
|
||||
hasHandledInitialTranscriptScroll = true
|
||||
}
|
||||
.onChange(of: isSending) { _, _ in
|
||||
scrollToBottom(with: proxy, animated: true)
|
||||
scrollToBottom(with: proxy, animated: hasHandledInitialTranscriptScroll)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,16 @@ struct SybilWorkspaceView: View {
|
||||
viewModel.errorMessage != nil
|
||||
}
|
||||
|
||||
private var transcriptScrollContextID: String {
|
||||
if viewModel.draftKind == .chat {
|
||||
return "draft-chat"
|
||||
}
|
||||
if case let .chat(chatID) = viewModel.selectedItem {
|
||||
return "chat:\(chatID)"
|
||||
}
|
||||
return "chat:none"
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
VStack(spacing: 0) {
|
||||
if showsHeader {
|
||||
@@ -53,6 +63,7 @@ struct SybilWorkspaceView: View {
|
||||
isLoading: viewModel.isLoadingSelection,
|
||||
isSending: viewModel.isSending
|
||||
)
|
||||
.id(transcriptScrollContextID)
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
|
||||
Reference in New Issue
Block a user