Expose network state to iOS bridge

This commit is contained in:
Mikhail Kilin
2026-05-21 00:36:08 +03:00
parent 3e67e0d1b8
commit b3b02835b6
6 changed files with 43 additions and 1 deletions

View File

@@ -493,6 +493,10 @@ impl SessionHandle {
self.with_session(|session| session.auth_state().into())
}
pub fn network_state(&self) -> IosNetworkState {
self.with_session(|session| session.network_state().into())
}
pub fn poll_events(&self) -> Vec<IosEvent> {
self.with_session(|session| {
session.drain_client_events();
@@ -909,6 +913,10 @@ impl SessionHandle {
.clone()
}
pub fn network_state(&self) -> IosNetworkState {
IosNetworkState::Ready
}
pub fn poll_events(&self) -> Vec<IosEvent> {
let mut state = self.state.lock().expect("session mutex poisoned");
std::mem::take(&mut state.events)
@@ -1296,6 +1304,7 @@ mod tests {
let chats = session.load_chats(20).unwrap();
assert_eq!(chats.len(), 1);
assert_eq!(session.network_state(), IosNetworkState::Ready);
let history = session.load_history(chats[0].id, 20).unwrap();
assert_eq!(history[0].text, "Hello from fake TDLib");