I am working with a navigationView with swiftUI. My problem is whenever I go to another view with a Navlink and the observedObject of the root of my navigationView changes, my interface come back to the root view also.
So my question is : Is there a way to tell the observedObject Of the root of the navigationView to stop updating the UI when I navigate to a navLink ?
The root of my navigationView: listChatViewModel is an Observable object and recentMessages is a Published Property
NavigationView{
ScrollView(.vertical, showsIndicators: false){
VStack(spacing : 6){
//Recent
ForEach(listChatViewModel.recentMessages){recentMessage in
NavigationLink(destination: ChatView(ChatViewModel(myUserId : self.session.session!.uid, userId : recentMessage.senderProfile!.user_id))) {
RecentCellView(recentMessage: recentMessage)
}
}
.padding()
}
}
.navigationBarTitle("Chat", displayMode: .inline)
.navigationBarItems(leading:
Image("logo_black").resizable().frame(width: 32.0, height: 32.0)
)
}
When I am in the ChatView and that the recentMessages property updates, this make me go back to the root view