fix: add photo_download_rx channel and fix account switcher nav tests
Some checks failed
CI / Check (pull_request) Has been cancelled
CI / Format (pull_request) Has been cancelled
CI / Clippy (pull_request) Has been cancelled
CI / Build (macos-latest) (pull_request) Has been cancelled
CI / Build (ubuntu-latest) (pull_request) Has been cancelled
CI / Build (windows-latest) (pull_request) Has been cancelled
Some checks failed
CI / Check (pull_request) Has been cancelled
CI / Format (pull_request) Has been cancelled
CI / Clippy (pull_request) Has been cancelled
CI / Build (macos-latest) (pull_request) Has been cancelled
CI / Build (ubuntu-latest) (pull_request) Has been cancelled
CI / Build (windows-latest) (pull_request) Has been cancelled
Add UnboundedReceiver for background photo downloads to App state, reset it on close_chat. Fix account_switcher tests to navigate past all accounts dynamically instead of assuming single account. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -83,6 +83,11 @@ impl<T: TdClientTrait> NavigationMethods<T> for App<T> {
|
||||
self.message_scroll_offset = 0;
|
||||
self.last_typing_sent = None;
|
||||
self.pending_chat_init = None;
|
||||
// Останавливаем фоновую загрузку фото (drop receiver)
|
||||
#[cfg(feature = "images")]
|
||||
{
|
||||
self.photo_download_rx = None;
|
||||
}
|
||||
// Сбрасываем состояние чата в нормальный режим
|
||||
self.chat_state = ChatState::Normal;
|
||||
self.input_mode = InputMode::Normal;
|
||||
|
||||
@@ -128,8 +128,12 @@ pub struct App<T: TdClientTrait = TdClient> {
|
||||
pub current_account_name: String,
|
||||
/// Pending account switch: (account_name, db_path)
|
||||
pub pending_account_switch: Option<(String, PathBuf)>,
|
||||
/// Pending background chat init (reply info, pinned, photos) after fast open
|
||||
/// Pending background chat init (reply info, pinned) after fast open
|
||||
pub pending_chat_init: Option<ChatId>,
|
||||
/// Receiver for background photo downloads (file_id, result path)
|
||||
#[cfg(feature = "images")]
|
||||
pub photo_download_rx:
|
||||
Option<tokio::sync::mpsc::UnboundedReceiver<(i32, Result<String, String>)>>,
|
||||
// Voice playback
|
||||
/// Аудиопроигрыватель для голосовых сообщений (rodio)
|
||||
pub audio_player: Option<crate::audio::AudioPlayer>,
|
||||
@@ -198,6 +202,8 @@ impl<T: TdClientTrait> App<T> {
|
||||
pending_account_switch: None,
|
||||
pending_chat_init: None,
|
||||
#[cfg(feature = "images")]
|
||||
photo_download_rx: None,
|
||||
#[cfg(feature = "images")]
|
||||
image_cache,
|
||||
#[cfg(feature = "images")]
|
||||
inline_image_renderer,
|
||||
|
||||
@@ -47,8 +47,15 @@ fn test_account_switcher_navigate_down() {
|
||||
let mut app = TestAppBuilder::new().build();
|
||||
app.open_account_switcher();
|
||||
|
||||
// Initially at 0, navigate down to "Add account" item
|
||||
app.account_switcher_select_next();
|
||||
let num_accounts = match &app.account_switcher {
|
||||
Some(AccountSwitcherState::SelectAccount { accounts, .. }) => accounts.len(),
|
||||
_ => panic!("Expected SelectAccount state"),
|
||||
};
|
||||
|
||||
// Navigate down past all accounts to "Add account" item
|
||||
for _ in 0..num_accounts {
|
||||
app.account_switcher_select_next();
|
||||
}
|
||||
|
||||
match &app.account_switcher {
|
||||
Some(AccountSwitcherState::SelectAccount {
|
||||
@@ -56,7 +63,7 @@ fn test_account_switcher_navigate_down() {
|
||||
accounts,
|
||||
..
|
||||
}) => {
|
||||
// Should be at index 1 (the "Add account" item, since default config has 1 account)
|
||||
// Should be at the "Add account" item (index == accounts.len())
|
||||
assert_eq!(*selected_index, accounts.len());
|
||||
}
|
||||
_ => panic!("Expected SelectAccount state"),
|
||||
@@ -116,8 +123,15 @@ fn test_confirm_add_account_transitions_to_add_state() {
|
||||
let mut app = TestAppBuilder::new().build();
|
||||
app.open_account_switcher();
|
||||
|
||||
// Navigate to "+ Add account"
|
||||
app.account_switcher_select_next();
|
||||
let num_accounts = match &app.account_switcher {
|
||||
Some(AccountSwitcherState::SelectAccount { accounts, .. }) => accounts.len(),
|
||||
_ => panic!("Expected SelectAccount state"),
|
||||
};
|
||||
|
||||
// Navigate past all accounts to "+ Add account"
|
||||
for _ in 0..num_accounts {
|
||||
app.account_switcher_select_next();
|
||||
}
|
||||
|
||||
// Confirm should transition to AddAccount
|
||||
app.account_switcher_confirm();
|
||||
|
||||
Reference in New Issue
Block a user