Better viewId for some tabs

This commit is contained in:
Thomas Ricouard 2023-01-29 11:52:11 +01:00
parent e84a57ed7f
commit e5b6e79fa9
3 changed files with 7 additions and 3 deletions

View File

@ -13,6 +13,7 @@ struct MessagesTab: View {
@EnvironmentObject private var watcher: StreamWatcher @EnvironmentObject private var watcher: StreamWatcher
@EnvironmentObject private var client: Client @EnvironmentObject private var client: Client
@EnvironmentObject private var currentAccount: CurrentAccount @EnvironmentObject private var currentAccount: CurrentAccount
@EnvironmentObject private var appAccount: AppAccountsManager
@StateObject private var routerPath = RouterPath() @StateObject private var routerPath = RouterPath()
@Binding var popToRootTab: Tab @Binding var popToRootTab: Tab
@ -29,7 +30,7 @@ struct MessagesTab: View {
} }
} }
.toolbarBackground(theme.primaryBackgroundColor.opacity(0.50), for: .navigationBar) .toolbarBackground(theme.primaryBackgroundColor.opacity(0.50), for: .navigationBar)
.id(currentAccount.account?.id) .id(appAccount.currentAccount.id)
} }
.onChange(of: $popToRootTab.wrappedValue) { popToRootTab in .onChange(of: $popToRootTab.wrappedValue) { popToRootTab in
if popToRootTab == .messages { if popToRootTab == .messages {

View File

@ -11,6 +11,7 @@ struct NotificationsTab: View {
@EnvironmentObject private var theme: Theme @EnvironmentObject private var theme: Theme
@EnvironmentObject private var client: Client @EnvironmentObject private var client: Client
@EnvironmentObject private var watcher: StreamWatcher @EnvironmentObject private var watcher: StreamWatcher
@EnvironmentObject private var appAccount: AppAccountsManager
@EnvironmentObject private var currentAccount: CurrentAccount @EnvironmentObject private var currentAccount: CurrentAccount
@EnvironmentObject private var userPreferences: UserPreferences @EnvironmentObject private var userPreferences: UserPreferences
@StateObject private var routerPath = RouterPath() @StateObject private var routerPath = RouterPath()
@ -33,7 +34,7 @@ struct NotificationsTab: View {
} }
} }
.toolbarBackground(theme.primaryBackgroundColor.opacity(0.50), for: .navigationBar) .toolbarBackground(theme.primaryBackgroundColor.opacity(0.50), for: .navigationBar)
.id(currentAccount.account?.id) .id(appAccount.currentAccount.id)
} }
.onAppear { .onAppear {
routerPath.client = client routerPath.client = client

View File

@ -8,6 +8,7 @@ import SwiftUI
import Timeline import Timeline
struct TimelineTab: View { struct TimelineTab: View {
@EnvironmentObject private var appAccount: AppAccountsManager
@EnvironmentObject private var theme: Theme @EnvironmentObject private var theme: Theme
@EnvironmentObject private var currentAccount: CurrentAccount @EnvironmentObject private var currentAccount: CurrentAccount
@EnvironmentObject private var preferences: UserPreferences @EnvironmentObject private var preferences: UserPreferences
@ -36,7 +37,7 @@ struct TimelineTab: View {
toolbarView toolbarView
} }
.toolbarBackground(theme.primaryBackgroundColor.opacity(0.50), for: .navigationBar) .toolbarBackground(theme.primaryBackgroundColor.opacity(0.50), for: .navigationBar)
.id(currentAccount.account?.id) .id(appAccount.currentAccount.id)
} }
.onAppear { .onAppear {
routerPath.client = client routerPath.client = client
@ -143,6 +144,7 @@ struct TimelineTab: View {
if UIDevice.current.userInterfaceIdiom != .pad { if UIDevice.current.userInterfaceIdiom != .pad {
ToolbarItem(placement: .navigationBarLeading) { ToolbarItem(placement: .navigationBarLeading) {
AppAccountsSelectorView(routerPath: routerPath) AppAccountsSelectorView(routerPath: routerPath)
.id(currentAccount.account?.id)
} }
} }
statusEditorToolbarItem(routerPath: routerPath, statusEditorToolbarItem(routerPath: routerPath,