use super::{FakeTdClient, TdUpdate}; use tele_tui::tdlib::types::FolderInfo; use tele_tui::tdlib::{AuthState, ChatInfo, MessageInfo, NetworkState, ProfileInfo}; use tokio::sync::mpsc; #[allow(dead_code)] impl FakeTdClient { /// Create an update channel for receiving simulated TDLib events. pub fn with_update_channel(self) -> (Self, mpsc::UnboundedReceiver) { let (tx, rx) = mpsc::unbounded_channel(); *self.update_tx.lock().unwrap() = Some(tx); (self, rx) } /// Enable simulated delays, closer to real TDLib behavior. pub fn with_delays(mut self) -> Self { self.simulate_delays = true; self } pub fn with_chat(self, chat: ChatInfo) -> Self { self.chats.lock().unwrap().push(chat); self } pub fn with_chats(self, chats: Vec) -> Self { self.chats.lock().unwrap().extend(chats); self } pub fn with_message(self, chat_id: i64, message: MessageInfo) -> Self { self.messages .lock() .unwrap() .entry(chat_id) .or_default() .push(message); self } pub fn with_messages(self, chat_id: i64, messages: Vec) -> Self { self.messages.lock().unwrap().insert(chat_id, messages); self } pub fn with_folder(self, id: i32, name: &str) -> Self { self.folders .lock() .unwrap() .push(FolderInfo { id, name: name.to_string() }); self } pub fn with_user(self, id: i64, name: &str) -> Self { self.user_names.lock().unwrap().insert(id, name.to_string()); self } pub fn with_profile(self, chat_id: i64, profile: ProfileInfo) -> Self { self.profiles.lock().unwrap().insert(chat_id, profile); self } pub fn with_network_state(self, state: NetworkState) -> Self { *self.network_state.lock().unwrap() = state; self } pub fn with_auth_state(self, state: AuthState) -> Self { *self.auth_state.lock().unwrap() = state; self } pub fn with_downloaded_file(self, file_id: i32, path: &str) -> Self { self.downloaded_files .lock() .unwrap() .insert(file_id, path.to_string()); self } pub fn with_available_reactions(self, reactions: Vec) -> Self { *self.available_reactions.lock().unwrap() = reactions; self } }