mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-12-25 22:42:38 +01:00
Fix #1772
This commit is contained in:
parent
c4bff07c40
commit
f3a48118f0
@ -18,16 +18,6 @@ extension IceCubesApp {
|
||||
SoundEffectManager.shared.playSound(.tabSelection)
|
||||
|
||||
selectedTab = newTab
|
||||
|
||||
DispatchQueue.main.async {
|
||||
if selectedTab == .notifications,
|
||||
let token = appAccountsManager.currentAccount.oauthToken
|
||||
{
|
||||
userPreferences.notificationsCount[token] = 0
|
||||
watcher.unreadNotificationsCount = 0
|
||||
}
|
||||
}
|
||||
|
||||
})) {
|
||||
ForEach(availableTabs) { tab in
|
||||
tab.makeContentView(popToRootTab: $popToRootTab)
|
||||
@ -44,6 +34,7 @@ extension IceCubesApp {
|
||||
}
|
||||
}
|
||||
.id(appAccountsManager.currentClient.id)
|
||||
.environment(\.selectedTab, selectedTab)
|
||||
}
|
||||
|
||||
private func badgeFor(tab: Tab) -> Int {
|
||||
|
@ -11,6 +11,7 @@ import Timeline
|
||||
struct NotificationsTab: View {
|
||||
@Environment(\.isSecondaryColumn) private var isSecondaryColumn: Bool
|
||||
@Environment(\.scenePhase) private var scenePhase
|
||||
@Environment(\.selectedTab) private var selectedTab: Tab
|
||||
|
||||
@Environment(Theme.self) private var theme
|
||||
@Environment(Client.self) private var client
|
||||
@ -58,9 +59,7 @@ struct NotificationsTab: View {
|
||||
}
|
||||
.onAppear {
|
||||
routerPath.client = client
|
||||
if isSecondaryColumn {
|
||||
clearNotifications()
|
||||
}
|
||||
clearNotifications()
|
||||
}
|
||||
.withSafariRouter()
|
||||
.environment(routerPath)
|
||||
@ -101,7 +100,7 @@ struct NotificationsTab: View {
|
||||
}
|
||||
|
||||
private func clearNotifications() {
|
||||
if isSecondaryColumn {
|
||||
if selectedTab == .notifications || isSecondaryColumn {
|
||||
if let token = appAccount.currentAccount.oauthToken {
|
||||
userPreferences.notificationsCount[token] = 0
|
||||
}
|
||||
|
@ -113,3 +113,14 @@ enum Tab: Int, Identifiable, Hashable {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private struct SelectedTab: EnvironmentKey {
|
||||
static let defaultValue: Tab = .timeline
|
||||
}
|
||||
|
||||
extension EnvironmentValues {
|
||||
var selectedTab: Tab {
|
||||
get { self[SelectedTab.self] }
|
||||
set { self[SelectedTab.self] = newValue }
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user