Fix account swap for favorites and bookmarks

This commit is contained in:
Thomas Ricouard 2024-01-04 16:53:10 +01:00
parent 9ec9c94c9a
commit 3d29c9e600
2 changed files with 18 additions and 0 deletions

View file

@ -2,6 +2,7 @@ import SwiftUI
import Env
import AppAccount
import DesignSystem
import Network
@MainActor
struct NavigationTab<Content: View>: View {
@ -11,6 +12,7 @@ struct NavigationTab<Content: View>: View {
@Environment(CurrentAccount.self) private var currentAccount
@Environment(UserPreferences.self) private var userPreferences
@Environment(Theme.self) private var theme
@Environment(Client.self) private var client
var content: () -> Content
@ -26,10 +28,18 @@ struct NavigationTab<Content: View>: View {
.withEnvironments()
.withAppRouter()
.withSheetDestinations(sheetDestinations: $routerPath.presentedSheet)
.withSafariRouter()
.toolbar {
ToolbarTab(routerPath: $routerPath)
}
.toolbarBackground(theme.primaryBackgroundColor.opacity(0.50), for: .navigationBar)
.onChange(of: client.id) {
routerPath.path = []
}
.onAppear {
routerPath.client = client
}
.withSafariRouter()
}
.environment(routerPath)
}

View file

@ -38,5 +38,13 @@ public struct AccountStatusesListView: View {
await viewModel.fetchNewestStatuses(pullToRefresh: false)
isLoaded = true
}
.onChange(of: client.id) { _, _ in
isLoaded = false
viewModel.client = client
Task {
await viewModel.fetchNewestStatuses(pullToRefresh: false)
isLoaded = true
}
}
}
}