mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2025-02-02 11:12:20 +00:00
Routeur: Handle same instance status url
This commit is contained in:
parent
e5fb3acd07
commit
9209258f4c
5 changed files with 20 additions and 0 deletions
|
@ -6,6 +6,7 @@ import Models
|
||||||
import Shimmer
|
import Shimmer
|
||||||
|
|
||||||
struct AccountTab: View {
|
struct AccountTab: View {
|
||||||
|
@EnvironmentObject private var client: Client
|
||||||
@EnvironmentObject private var currentAccount: CurrentAccount
|
@EnvironmentObject private var currentAccount: CurrentAccount
|
||||||
@StateObject private var routeurPath = RouterPath()
|
@StateObject private var routeurPath = RouterPath()
|
||||||
@Binding var popToRootTab: IceCubesApp.Tab
|
@Binding var popToRootTab: IceCubesApp.Tab
|
||||||
|
@ -28,5 +29,8 @@ struct AccountTab: View {
|
||||||
routeurPath.path = []
|
routeurPath.path = []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.onAppear {
|
||||||
|
routeurPath.client = client
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,11 @@ import Env
|
||||||
import Models
|
import Models
|
||||||
import Shimmer
|
import Shimmer
|
||||||
import Explore
|
import Explore
|
||||||
|
import Env
|
||||||
|
import Network
|
||||||
|
|
||||||
struct ExploreTab: View {
|
struct ExploreTab: View {
|
||||||
|
@EnvironmentObject private var client: Client
|
||||||
@StateObject private var routeurPath = RouterPath()
|
@StateObject private var routeurPath = RouterPath()
|
||||||
@Binding var popToRootTab: IceCubesApp.Tab
|
@Binding var popToRootTab: IceCubesApp.Tab
|
||||||
|
|
||||||
|
@ -20,5 +23,8 @@ struct ExploreTab: View {
|
||||||
routeurPath.path = []
|
routeurPath.path = []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.onAppear {
|
||||||
|
routeurPath.client = client
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import Network
|
||||||
import Notifications
|
import Notifications
|
||||||
|
|
||||||
struct NotificationsTab: View {
|
struct NotificationsTab: View {
|
||||||
|
@EnvironmentObject private var client: Client
|
||||||
@EnvironmentObject private var watcher: StreamWatcher
|
@EnvironmentObject private var watcher: StreamWatcher
|
||||||
@StateObject private var routeurPath = RouterPath()
|
@StateObject private var routeurPath = RouterPath()
|
||||||
@Binding var popToRootTab: IceCubesApp.Tab
|
@Binding var popToRootTab: IceCubesApp.Tab
|
||||||
|
@ -16,6 +17,7 @@ struct NotificationsTab: View {
|
||||||
.withSheetDestinations(sheetDestinations: $routeurPath.presentedSheet)
|
.withSheetDestinations(sheetDestinations: $routeurPath.presentedSheet)
|
||||||
}
|
}
|
||||||
.onAppear {
|
.onAppear {
|
||||||
|
routeurPath.client = client
|
||||||
watcher.unreadNotificationsCount = 0
|
watcher.unreadNotificationsCount = 0
|
||||||
}
|
}
|
||||||
.environmentObject(routeurPath)
|
.environmentObject(routeurPath)
|
||||||
|
|
|
@ -31,6 +31,7 @@ struct TimelineTab: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.onAppear {
|
.onAppear {
|
||||||
|
routeurPath.client = client
|
||||||
if !client.isAuth {
|
if !client.isAuth {
|
||||||
timeline = .pub
|
timeline = .pub
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import Foundation
|
import Foundation
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
import Models
|
import Models
|
||||||
|
import Network
|
||||||
|
|
||||||
public enum RouteurDestinations: Hashable {
|
public enum RouteurDestinations: Hashable {
|
||||||
case accountDetail(id: String)
|
case accountDetail(id: String)
|
||||||
|
@ -28,6 +29,8 @@ public enum SheetDestinations: Identifiable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public class RouterPath: ObservableObject {
|
public class RouterPath: ObservableObject {
|
||||||
|
public var client: Client?
|
||||||
|
|
||||||
@Published public var path: [RouteurDestinations] = []
|
@Published public var path: [RouteurDestinations] = []
|
||||||
@Published public var presentedSheet: SheetDestinations?
|
@Published public var presentedSheet: SheetDestinations?
|
||||||
|
|
||||||
|
@ -45,6 +48,10 @@ public class RouterPath: ObservableObject {
|
||||||
} else if let mention = status.mentions.first(where: { $0.url == url }) {
|
} else if let mention = status.mentions.first(where: { $0.url == url }) {
|
||||||
navigate(to: .accountDetail(id: mention.id))
|
navigate(to: .accountDetail(id: mention.id))
|
||||||
return .handled
|
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
|
return .systemAction
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue