From 3b9144cd289fbc6f68e00cdc2e3d7e57e41e7329 Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Thu, 23 Apr 2026 23:19:39 +0200 Subject: [PATCH] Fix macOS sidebar dynamic item switching --- Yattee/Views/Navigation/UnifiedTabView.swift | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Yattee/Views/Navigation/UnifiedTabView.swift b/Yattee/Views/Navigation/UnifiedTabView.swift index 5d34da5c..96996664 100644 --- a/Yattee/Views/Navigation/UnifiedTabView.swift +++ b/Yattee/Views/Navigation/UnifiedTabView.swift @@ -879,8 +879,8 @@ extension UnifiedTabView { homePath.append(destination) case .search: searchPath.append(destination) - case .channel(let channelID, _, _): - channelPaths[channelID, default: NavigationPath()].append(destination) + case .channel: + channelPaths[selection.id, default: NavigationPath()].append(destination) case .playlist(let id, _): playlistPaths[id, default: NavigationPath()].append(destination) case .mediaSource(let id, _, _): @@ -919,10 +919,10 @@ extension UnifiedTabView { // MARK: - Path Bindings - func channelPathBinding(for channelID: String) -> Binding { + func channelPathBinding(for item: SidebarItem) -> Binding { Binding( - get: { channelPaths[channelID] ?? NavigationPath() }, - set: { channelPaths[channelID] = $0 } + get: { channelPaths[item.id] ?? NavigationPath() }, + set: { channelPaths[item.id] = $0 } ) } @@ -952,10 +952,11 @@ extension UnifiedTabView { @ViewBuilder func channelContent(for item: SidebarItem) -> some View { if case .channel(let channelID, _, let source) = item { - NavigationStack(path: channelPathBinding(for: channelID)) { + NavigationStack(path: channelPathBinding(for: item)) { ChannelView(channelID: channelID, source: source) .withNavigationDestinations() } + .id(item.id) } } @@ -983,6 +984,7 @@ extension UnifiedTabView { UnifiedPlaylistDetailView(source: .local(id)) .withNavigationDestinations() } + .id(item.id) } } @@ -1007,6 +1009,7 @@ extension UnifiedTabView { MediaBrowserView(source: source, path: "/") .withNavigationDestinations() } + .id(item.id) } } @@ -1020,6 +1023,7 @@ extension UnifiedTabView { InstanceBrowseView(instance: instance) .withNavigationDestinations() } + .id(item.id) } }