Don't open link on secondary column

This commit is contained in:
Thomas Ricouard 2024-05-13 09:27:24 +02:00
parent e21ec0bd1f
commit a8039df22d
2 changed files with 6 additions and 2 deletions

View file

@ -13,6 +13,7 @@ extension View {
@MainActor @MainActor
private struct SafariRouter: ViewModifier { private struct SafariRouter: ViewModifier {
@Environment(\.isSecondaryColumn) private var isSecondaryColumn: Bool
@Environment(Theme.self) private var theme @Environment(Theme.self) private var theme
@Environment(UserPreferences.self) private var preferences @Environment(UserPreferences.self) private var preferences
@Environment(RouterPath.self) private var routerPath @Environment(RouterPath.self) private var routerPath
@ -25,10 +26,12 @@ private struct SafariRouter: ViewModifier {
content content
.environment(\.openURL, OpenURLAction { url in .environment(\.openURL, OpenURLAction { url in
// Open internal URL. // Open internal URL.
routerPath.handle(url: url) guard !isSecondaryColumn else { return .discarded }
return routerPath.handle(url: url)
}) })
.onOpenURL { url in .onOpenURL { url in
// Open external URL (from icecubesapp://) // Open external URL (from icecubesapp://)
guard !isSecondaryColumn else { return }
let urlString = url.absoluteString.replacingOccurrences(of: AppInfo.scheme, with: "https://") let urlString = url.absoluteString.replacingOccurrences(of: AppInfo.scheme, with: "https://")
guard let url = URL(string: urlString), url.host != nil else { return } guard let url = URL(string: urlString), url.host != nil else { return }
_ = routerPath.handleDeepLink(url: url) _ = routerPath.handleDeepLink(url: url)

View file

@ -111,7 +111,8 @@ struct SideBarView<Content: View>: View {
isInSettings: false), isInSettings: false),
isParentPresented: .constant(false)) isParentPresented: .constant(false))
} }
if showBadge, if !userPreferences.isSidebarExpanded,
showBadge,
let token = account.oauthToken, let token = account.oauthToken,
let notificationsCount = userPreferences.notificationsCount[token], let notificationsCount = userPreferences.notificationsCount[token],
notificationsCount > 0 notificationsCount > 0