commit 0563ec8bf86585a7bc0246c25af1d1af0c992b52
parent 29c41708332bd6855a0cc23400f76274d228cbbc
Author: William Casarin <jb55@jb55.com>
Date: Tue, 7 Feb 2023 14:06:27 -0800
Fix issue where navigation fails pop to root when switching timelines
Sometimes the navigation stack fails to pop, fix this
Changelog-Fixed: Fix issue where navigation fails pop to root when switching timelines
Diffstat:
2 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/damus/ContentView.swift b/damus/ContentView.swift
@@ -138,6 +138,12 @@ struct ContentView: View {
}
}
+ func popToRoot() {
+ profile_open = false
+ thread_open = false
+ search_open = false
+ }
+
func MainContent(damus: DamusState) -> some View {
VStack {
NavigationLink(destination: MaybeProfileView, isActive: $profile_open) {
@@ -520,6 +526,7 @@ struct ContentView: View {
}
func switch_timeline(_ timeline: Timeline) {
+ self.popToRoot()
NotificationCenter.default.post(name: .switched_timeline, object: timeline)
if timeline == self.selected_timeline {
diff --git a/damus/Views/Relays/RelayDetailView.swift b/damus/Views/Relays/RelayDetailView.swift
@@ -16,6 +16,8 @@ struct RelayDetailView: View {
@State var conn_color: Color
+ @Environment(\.dismiss) var dismiss
+
func FieldText(_ str: String?) -> some View {
Text(str ?? "No data available")
}
@@ -64,6 +66,9 @@ struct RelayDetailView: View {
ProgressView()
}
}
+ .onReceive(handle_notify(.switched_timeline)) { notif in
+ dismiss()
+ }
.navigationTitle(nip11?.name ?? "")
.task {
var urlString = relay.replacingOccurrences(of: "wss://", with: "https://")