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.message_scroll_offset = 0;
|
||||||
self.last_typing_sent = None;
|
self.last_typing_sent = None;
|
||||||
self.pending_chat_init = None;
|
self.pending_chat_init = None;
|
||||||
|
// Останавливаем фоновую загрузку фото (drop receiver)
|
||||||
|
#[cfg(feature = "images")]
|
||||||
|
{
|
||||||
|
self.photo_download_rx = None;
|
||||||
|
}
|
||||||
// Сбрасываем состояние чата в нормальный режим
|
// Сбрасываем состояние чата в нормальный режим
|
||||||
self.chat_state = ChatState::Normal;
|
self.chat_state = ChatState::Normal;
|
||||||
self.input_mode = InputMode::Normal;
|
self.input_mode = InputMode::Normal;
|
||||||
|
|||||||
@@ -128,8 +128,12 @@ pub struct App<T: TdClientTrait = TdClient> {
|
|||||||
pub current_account_name: String,
|
pub current_account_name: String,
|
||||||
/// Pending account switch: (account_name, db_path)
|
/// Pending account switch: (account_name, db_path)
|
||||||
pub pending_account_switch: Option<(String, PathBuf)>,
|
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>,
|
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
|
// Voice playback
|
||||||
/// Аудиопроигрыватель для голосовых сообщений (rodio)
|
/// Аудиопроигрыватель для голосовых сообщений (rodio)
|
||||||
pub audio_player: Option<crate::audio::AudioPlayer>,
|
pub audio_player: Option<crate::audio::AudioPlayer>,
|
||||||
@@ -198,6 +202,8 @@ impl<T: TdClientTrait> App<T> {
|
|||||||
pending_account_switch: None,
|
pending_account_switch: None,
|
||||||
pending_chat_init: None,
|
pending_chat_init: None,
|
||||||
#[cfg(feature = "images")]
|
#[cfg(feature = "images")]
|
||||||
|
photo_download_rx: None,
|
||||||
|
#[cfg(feature = "images")]
|
||||||
image_cache,
|
image_cache,
|
||||||
#[cfg(feature = "images")]
|
#[cfg(feature = "images")]
|
||||||
inline_image_renderer,
|
inline_image_renderer,
|
||||||
|
|||||||
@@ -47,8 +47,15 @@ fn test_account_switcher_navigate_down() {
|
|||||||
let mut app = TestAppBuilder::new().build();
|
let mut app = TestAppBuilder::new().build();
|
||||||
app.open_account_switcher();
|
app.open_account_switcher();
|
||||||
|
|
||||||
// Initially at 0, navigate down to "Add account" item
|
let num_accounts = match &app.account_switcher {
|
||||||
app.account_switcher_select_next();
|
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 {
|
match &app.account_switcher {
|
||||||
Some(AccountSwitcherState::SelectAccount {
|
Some(AccountSwitcherState::SelectAccount {
|
||||||
@@ -56,7 +63,7 @@ fn test_account_switcher_navigate_down() {
|
|||||||
accounts,
|
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());
|
assert_eq!(*selected_index, accounts.len());
|
||||||
}
|
}
|
||||||
_ => panic!("Expected SelectAccount state"),
|
_ => panic!("Expected SelectAccount state"),
|
||||||
@@ -116,8 +123,15 @@ fn test_confirm_add_account_transitions_to_add_state() {
|
|||||||
let mut app = TestAppBuilder::new().build();
|
let mut app = TestAppBuilder::new().build();
|
||||||
app.open_account_switcher();
|
app.open_account_switcher();
|
||||||
|
|
||||||
// Navigate to "+ Add account"
|
let num_accounts = match &app.account_switcher {
|
||||||
app.account_switcher_select_next();
|
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
|
// Confirm should transition to AddAccount
|
||||||
app.account_switcher_confirm();
|
app.account_switcher_confirm();
|
||||||
|
|||||||
Reference in New Issue
Block a user