fix(polls): prevent jarring reload when switching to My Trips tab
- Only load polls once on initial view appearance, not every tab switch - Only show spinner when there's no existing data (first load) - Subsequent refreshes update content in place without showing spinner Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -411,6 +411,7 @@ struct SavedTripsListView: View {
|
|||||||
|
|
||||||
@State private var polls: [TripPoll] = []
|
@State private var polls: [TripPoll] = []
|
||||||
@State private var isLoadingPolls = false
|
@State private var isLoadingPolls = false
|
||||||
|
@State private var hasLoadedPolls = false
|
||||||
@State private var showCreatePoll = false
|
@State private var showCreatePoll = false
|
||||||
@State private var selectedPoll: TripPoll?
|
@State private var selectedPoll: TripPoll?
|
||||||
|
|
||||||
@@ -437,6 +438,8 @@ struct SavedTripsListView: View {
|
|||||||
}
|
}
|
||||||
.themedBackground()
|
.themedBackground()
|
||||||
.task {
|
.task {
|
||||||
|
guard !hasLoadedPolls else { return }
|
||||||
|
hasLoadedPolls = true
|
||||||
await loadPolls()
|
await loadPolls()
|
||||||
}
|
}
|
||||||
.refreshable {
|
.refreshable {
|
||||||
@@ -474,7 +477,7 @@ struct SavedTripsListView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if isLoadingPolls {
|
if isLoadingPolls && polls.isEmpty {
|
||||||
ProgressView()
|
ProgressView()
|
||||||
.frame(maxWidth: .infinity, alignment: .center)
|
.frame(maxWidth: .infinity, alignment: .center)
|
||||||
.padding()
|
.padding()
|
||||||
|
|||||||
Reference in New Issue
Block a user