Add iOS session bridge factory
This commit is contained in:
@@ -16,6 +16,9 @@ struct TeleTuiIOSApp: App {
|
||||
displayName: "Fake",
|
||||
databasePath: paths.databasePath(for: "fake")
|
||||
)
|
||||
return SessionStore(account: account, bridge: FakeSessionBridge(auth: .ready))
|
||||
return SessionStore(
|
||||
account: account,
|
||||
bridge: SessionBridgeFactory.makeDefaultBridge(account: account)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
import Foundation
|
||||
|
||||
public enum SessionBridgeFactory {
|
||||
public static func makeDefaultBridge(
|
||||
account: Account,
|
||||
useFakeTdlib: Bool = true
|
||||
) -> SessionBridge {
|
||||
#if canImport(tele_ios_ffiFFI)
|
||||
do {
|
||||
return try UniFfiSessionBridge(account: account, useFakeTdlib: useFakeTdlib)
|
||||
} catch {
|
||||
return FakeSessionBridge(auth: .waitPhoneNumber)
|
||||
}
|
||||
#else
|
||||
return FakeSessionBridge(auth: .ready)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ struct TeleTuiIOSSmokeTests {
|
||||
try await chatListLoadsDeterministicFakeDataAndFilters()
|
||||
try await chatDetailLoadsAndSendsMessage()
|
||||
try await messageActionsCoverEditReplyForwardReactDeleteSearchAndCopy()
|
||||
try await sessionBridgeFactoryUsesAvailableDefaultBridge()
|
||||
try await platformServicesCoverNotificationsMediaVoiceClipboardAndAccounts()
|
||||
lifecycleCoordinatorDropsStaleAccountEvents()
|
||||
try await profileLoadsFromSelectedChat()
|
||||
@@ -127,6 +128,14 @@ struct TeleTuiIOSSmokeTests {
|
||||
precondition(!viewModel.messages.contains { $0.id == 1 })
|
||||
}
|
||||
|
||||
@MainActor
|
||||
private static func sessionBridgeFactoryUsesAvailableDefaultBridge() async throws {
|
||||
let account = Account(id: "factory", displayName: "Factory", databasePath: URL(fileURLWithPath: "/tmp/factory"))
|
||||
let bridge = SessionBridgeFactory.makeDefaultBridge(account: account)
|
||||
let auth = try await bridge.authState()
|
||||
precondition(auth == .ready)
|
||||
}
|
||||
|
||||
@MainActor
|
||||
private static func platformServicesCoverNotificationsMediaVoiceClipboardAndAccounts() async throws {
|
||||
let root = URL(fileURLWithPath: "/tmp/TeleTuiIOS")
|
||||
|
||||
Reference in New Issue
Block a user