Routeur: Handle same instance status url
This commit is contained in:
parent
e5fb3acd07
commit
9209258f4c
|
@ -6,6 +6,7 @@ import Models
|
|||
import Shimmer
|
||||
|
||||
struct AccountTab: View {
|
||||
@EnvironmentObject private var client: Client
|
||||
@EnvironmentObject private var currentAccount: CurrentAccount
|
||||
@StateObject private var routeurPath = RouterPath()
|
||||
@Binding var popToRootTab: IceCubesApp.Tab
|
||||
|
@ -28,5 +29,8 @@ struct AccountTab: View {
|
|||
routeurPath.path = []
|
||||
}
|
||||
}
|
||||
.onAppear {
|
||||
routeurPath.client = client
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,8 +3,11 @@ import Env
|
|||
import Models
|
||||
import Shimmer
|
||||
import Explore
|
||||
import Env
|
||||
import Network
|
||||
|
||||
struct ExploreTab: View {
|
||||
@EnvironmentObject private var client: Client
|
||||
@StateObject private var routeurPath = RouterPath()
|
||||
@Binding var popToRootTab: IceCubesApp.Tab
|
||||
|
||||
|
@ -20,5 +23,8 @@ struct ExploreTab: View {
|
|||
routeurPath.path = []
|
||||
}
|
||||
}
|
||||
.onAppear {
|
||||
routeurPath.client = client
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import Network
|
|||
import Notifications
|
||||
|
||||
struct NotificationsTab: View {
|
||||
@EnvironmentObject private var client: Client
|
||||
@EnvironmentObject private var watcher: StreamWatcher
|
||||
@StateObject private var routeurPath = RouterPath()
|
||||
@Binding var popToRootTab: IceCubesApp.Tab
|
||||
|
@ -16,6 +17,7 @@ struct NotificationsTab: View {
|
|||
.withSheetDestinations(sheetDestinations: $routeurPath.presentedSheet)
|
||||
}
|
||||
.onAppear {
|
||||
routeurPath.client = client
|
||||
watcher.unreadNotificationsCount = 0
|
||||
}
|
||||
.environmentObject(routeurPath)
|
||||
|
|
|
@ -31,6 +31,7 @@ struct TimelineTab: View {
|
|||
}
|
||||
}
|
||||
.onAppear {
|
||||
routeurPath.client = client
|
||||
if !client.isAuth {
|
||||
timeline = .pub
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import Foundation
|
||||
import SwiftUI
|
||||
import Models
|
||||
import Network
|
||||
|
||||
public enum RouteurDestinations: Hashable {
|
||||
case accountDetail(id: String)
|
||||
|
@ -28,6 +29,8 @@ public enum SheetDestinations: Identifiable {
|
|||
}
|
||||
|
||||
public class RouterPath: ObservableObject {
|
||||
public var client: Client?
|
||||
|
||||
@Published public var path: [RouteurDestinations] = []
|
||||
@Published public var presentedSheet: SheetDestinations?
|
||||
|
||||
|
@ -45,6 +48,10 @@ public class RouterPath: ObservableObject {
|
|||
} else if let mention = status.mentions.first(where: { $0.url == url }) {
|
||||
navigate(to: .accountDetail(id: mention.id))
|
||||
return .handled
|
||||
} else if let client = client,
|
||||
let id = status.content.findStatusesIds(instance: client.server)?.first(where: { String($0) == url.lastPathComponent}) {
|
||||
navigate(to: .statusDetail(id: String(id)))
|
||||
return .handled
|
||||
}
|
||||
return .systemAction
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue