Hi, just an upgrade to close the topic. Moving to Observation is not an option as it will force me to drop iOS 16 support and I would like always to maintain support for minimum 3 iOS versions.
I also tried suggested on point 2, among things but nothing worked.
Finally, I analysed other parts of the code where I had something similar but worked, and came out with the fact that only had this issue when the work on .onAppear was fast. In other screens where I do some processing onAppear, it worked.
So I ended adding a subtle sleep inside .onAppear which "fixed" the issue.
.onAppear{
Task {
await nextWeekViewModel.processNextWeek(team: team)
if nextWeekViewModel.finishedProcessing {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
self.navigate = true
}
}
}
}
It's not ideal but it seems that the underlying problem is fixed in iOS18 so I accept this as a workaround for iOS16/IOS17.
Thanks for the help.