Skip to content

Commit da8bc03

Browse files
committed
Update scroll to bottom timing
1 parent 75493d7 commit da8bc03

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

Core/Sources/ChatGPTChatTab/ChatPanel.swift

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ struct ChatPanelMessages: View {
4949
@Namespace var scrollSpace
5050
@State var scrollOffset: Double = 0
5151
@State var listHeight: Double = 0
52-
@State var didAppearOnce = false
52+
@State var didScrollToBottomOnAppearOnce = false
5353
@State var isBottomHidden = true
5454
@Environment(\.isEnabled) var isEnabled
5555

@@ -76,19 +76,14 @@ struct ChatPanelMessages: View {
7676
.id(bottomID)
7777
.onAppear {
7878
isBottomHidden = false
79-
if !didAppearOnce {
79+
if !didScrollToBottomOnAppearOnce {
8080
proxy.scrollTo(bottomID, anchor: .bottom)
81+
didScrollToBottomOnAppearOnce = true
8182
}
8283
}
8384
.onDisappear {
8485
isBottomHidden = true
8586
}
86-
.task {
87-
if !didAppearOnce {
88-
proxy.scrollTo(bottomID, anchor: .bottom)
89-
didAppearOnce = true
90-
}
91-
}
9287
.background(GeometryReader { geo in
9388
let offset = geo.frame(in: .named(scrollSpace)).minY
9489
Color.clear.preference(
@@ -150,6 +145,12 @@ struct ChatPanelMessages: View {
150145
proxy.scrollTo(bottomID, anchor: .bottom)
151146
}
152147
}
148+
.onAppear {
149+
proxy.scrollTo(bottomID, anchor: .bottom)
150+
}
151+
.task {
152+
proxy.scrollTo(bottomID, anchor: .bottom)
153+
}
153154
}
154155
}
155156
.onAppear {

0 commit comments

Comments
 (0)