Preserve typing events in iOS FFI
This commit is contained in:
@@ -173,6 +173,7 @@ public enum SessionEvent: Equatable, Sendable {
|
||||
case reactionChanged(Int64, Int64, [Reaction])
|
||||
case incomingNotificationCandidate(ChatSummary, Message, String)
|
||||
case networkChanged(NetworkState)
|
||||
case typingChanged(TypingState)
|
||||
case draftChanged(Draft)
|
||||
case profileLoaded(Profile)
|
||||
case mediaDownloadProgress(fileId: Int32, downloadedSize: Int64, totalSize: Int64)
|
||||
@@ -185,3 +186,8 @@ public enum NetworkState: Equatable, Sendable {
|
||||
case updating
|
||||
case ready
|
||||
}
|
||||
|
||||
public enum TypingState: Equatable, Sendable {
|
||||
case idle
|
||||
case typing(chatId: Int64, userId: Int64, text: String)
|
||||
}
|
||||
|
||||
@@ -155,6 +155,15 @@ public actor UniFfiSessionBridge: SessionBridge {
|
||||
}
|
||||
}
|
||||
|
||||
private static func mapTypingState(_ state: IosTypingState) -> TypingState {
|
||||
switch state {
|
||||
case .idle:
|
||||
.idle
|
||||
case let .typing(chatId, userId, text):
|
||||
.typing(chatId: chatId, userId: userId, text: text)
|
||||
}
|
||||
}
|
||||
|
||||
private static func mapFolder(_ folder: IosFolder) -> Folder {
|
||||
Folder(id: folder.id, name: folder.name)
|
||||
}
|
||||
@@ -236,6 +245,8 @@ public actor UniFfiSessionBridge: SessionBridge {
|
||||
)
|
||||
case let .networkChanged(state):
|
||||
.networkChanged(mapNetworkState(state))
|
||||
case let .typingChanged(state):
|
||||
.typingChanged(mapTypingState(state))
|
||||
case let .draftChanged(draft):
|
||||
.draftChanged(mapDraft(draft))
|
||||
case let .profileLoaded(profile):
|
||||
|
||||
@@ -6,6 +6,7 @@ public final class SessionStore: ObservableObject {
|
||||
@Published public private(set) var account: Account
|
||||
@Published public private(set) var authState: AuthState = .waitTdlibParameters
|
||||
@Published public private(set) var networkState: NetworkState = .ready
|
||||
@Published public private(set) var typingState: TypingState = .idle
|
||||
@Published public private(set) var errorMessage: String?
|
||||
|
||||
public let bridge: SessionBridge
|
||||
@@ -40,6 +41,8 @@ public final class SessionStore: ObservableObject {
|
||||
authState = state
|
||||
case let .networkChanged(state):
|
||||
networkState = state
|
||||
case let .typingChanged(state):
|
||||
typingState = state
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
||||
@@ -25,6 +25,8 @@ struct TeleTuiIOSSmokeTests {
|
||||
precondition(store.authState == .waitPhoneNumber)
|
||||
await store.refreshNetworkState()
|
||||
precondition(store.networkState == .ready)
|
||||
store.apply(events: [.typingChanged(.typing(chatId: 1, userId: 10, text: "typing"))])
|
||||
precondition(store.typingState == .typing(chatId: 1, userId: 10, text: "typing"))
|
||||
|
||||
viewModel.phone = "+10000000000"
|
||||
await viewModel.submitCurrentStep()
|
||||
|
||||
Reference in New Issue
Block a user