From 23cf2a37512bb259cfb8886ed692a019d009478e Mon Sep 17 00:00:00 2001 From: Thomas Ricouard Date: Wed, 18 Jan 2023 13:51:24 +0100 Subject: [PATCH] Faster & Safer account switching on macOS --- IceCubesApp/App/IceCubesApp.swift | 5 ++++- IceCubesApp/App/Tabs/Timeline/TimelineTab.swift | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/IceCubesApp/App/IceCubesApp.swift b/IceCubesApp/App/IceCubesApp.swift index 3b10cbd2..12261891 100644 --- a/IceCubesApp/App/IceCubesApp.swift +++ b/IceCubesApp/App/IceCubesApp.swift @@ -99,7 +99,8 @@ struct IceCubesApp: App { tab .makeContentView(popToRootTab: $popToRootTab) .opacity(tab == selectedTab ? 1 : 0) - .id(tab) + .transition(.opacity) + .id("\(tab)\(appAccountsManager.currentAccount.id)") .onAppear { sideBarLoadedTabs.insert(tab) } @@ -108,6 +109,8 @@ struct IceCubesApp: App { } } } + }.onChange(of: $appAccountsManager.currentAccount.id) { _ in + sideBarLoadedTabs.removeAll() } } diff --git a/IceCubesApp/App/Tabs/Timeline/TimelineTab.swift b/IceCubesApp/App/Tabs/Timeline/TimelineTab.swift index 73e9fc6e..6f840a7b 100644 --- a/IceCubesApp/App/Tabs/Timeline/TimelineTab.swift +++ b/IceCubesApp/App/Tabs/Timeline/TimelineTab.swift @@ -54,7 +54,7 @@ struct TimelineTab: View { timeline = isAuth ? .home : .federated }) .onChange(of: currentAccount.account?.id, perform: { _ in - timeline = client.isAuth ? .home : .federated + timeline = client.isAuth && canFilterTimeline ? .home : .federated }) .onChange(of: $popToRootTab.wrappedValue) { popToRootTab in if popToRootTab == .timeline {