Browse Source

Always trigger switch timeline on tab press

This will dismiss views

Changelog-Fixed: Fix bug where sometimes nested navigation views weren't dismissed when tapping the tab bar
Signed-off-by: William Casarin <jb55@jb55.com>
profile-edit
William Casarin 2 years ago
parent
commit
d223d045e8
  1. 4
      damus/ContentView.swift
  2. 6
      damus/Views/ProfileView.swift

4
damus/ContentView.swift

@ -311,13 +311,15 @@ struct ContentView: View {
} }
func switch_timeline(_ timeline: Timeline) { func switch_timeline(_ timeline: Timeline) {
NotificationCenter.default.post(name: .switched_timeline, object: timeline)
if timeline == self.selected_timeline { if timeline == self.selected_timeline {
NotificationCenter.default.post(name: .scroll_to_top, object: nil) NotificationCenter.default.post(name: .scroll_to_top, object: nil)
return return
} }
self.selected_timeline = timeline self.selected_timeline = timeline
NotificationCenter.default.post(name: .switched_timeline, object: timeline) //NotificationCenter.default.post(name: .switched_timeline, object: timeline)
//self.selected_timeline = timeline //self.selected_timeline = timeline
} }

6
damus/Views/ProfileView.swift

@ -73,6 +73,8 @@ struct ProfileView: View {
@StateObject var profile: ProfileModel @StateObject var profile: ProfileModel
@StateObject var followers: FollowersModel @StateObject var followers: FollowersModel
@Environment(\.dismiss) var dismiss
//@EnvironmentObject var profile: ProfileModel //@EnvironmentObject var profile: ProfileModel
var DMButton: some View { var DMButton: some View {
@ -150,8 +152,10 @@ struct ProfileView: View {
} }
.padding([.leading, .trailing], 6) .padding([.leading, .trailing], 6)
.frame(maxWidth: .infinity, alignment: .topLeading) .frame(maxWidth: .infinity, alignment: .topLeading)
.navigationBarTitle("Profile") .navigationBarTitle("Profile")
.onReceive(handle_notify(.switched_timeline)) { _ in
dismiss()
}
.onAppear() { .onAppear() {
profile.subscribe() profile.subscribe()
followers.subscribe() followers.subscribe()

Loading…
Cancel
Save