From 52ab162a6cd9fa88c469dc77900662f464f60ac1 Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Tue, 30 Nov 2021 23:58:46 +0100 Subject: [PATCH] Fix crash caused by tab navigation --- Shared/Navigation/AppTabNavigation.swift | 51 +++++++++++++----------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/Shared/Navigation/AppTabNavigation.swift b/Shared/Navigation/AppTabNavigation.swift index 2613112e..3c40f92f 100644 --- a/Shared/Navigation/AppTabNavigation.swift +++ b/Shared/Navigation/AppTabNavigation.swift @@ -72,34 +72,39 @@ struct AppTabNavigation: View { } .tag(TabSelection.search) } + .id(accounts.current?.id ?? "") .environment(\.navigationStyle, .tab) - .sheet(isPresented: $navigation.presentingChannel, onDismiss: { - if let channel = recents.presentedChannel { - recents.close(RecentItem(from: channel)) - } - }) { - if let channel = recents.presentedChannel { - NavigationView { - ChannelVideosView(channel: channel) - .environment(\.inChannelView, true) - .environment(\.inNavigationView, true) - .background(playerNavigationLink) + .background( + EmptyView().sheet(isPresented: $navigation.presentingChannel, onDismiss: { + if let channel = recents.presentedChannel { + recents.close(RecentItem(from: channel)) + } + }) { + if let channel = recents.presentedChannel { + NavigationView { + ChannelVideosView(channel: channel) + .environment(\.inChannelView, true) + .environment(\.inNavigationView, true) + .background(playerNavigationLink) + } } } - } - .sheet(isPresented: $navigation.presentingPlaylist, onDismiss: { - if let playlist = recents.presentedPlaylist { - recents.close(RecentItem(from: playlist)) - } - }) { - if let playlist = recents.presentedPlaylist { - NavigationView { - ChannelPlaylistView(playlist: playlist) - .environment(\.inNavigationView, true) - .background(playerNavigationLink) + ) + .background( + EmptyView().sheet(isPresented: $navigation.presentingPlaylist, onDismiss: { + if let playlist = recents.presentedPlaylist { + recents.close(RecentItem(from: playlist)) + } + }) { + if let playlist = recents.presentedPlaylist { + NavigationView { + ChannelPlaylistView(playlist: playlist) + .environment(\.inNavigationView, true) + .background(playerNavigationLink) + } } } - } + ) } private var subscriptionsVisible: Bool {