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

View file

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