refactor: complete Phase 13 deep architecture refactoring (etaps 3-7)
Split monolithic files into modular architecture: - ui/messages.rs (893→365 lines): extract modals/, compose_bar.rs - tdlib/messages.rs (836→3 files): split into messages/mod, convert, operations - config/mod.rs (642→3 files): extract validation.rs, loader.rs - Code duplication cleanup: shared components, ~220 lines removed - Documentation: PROJECT_STRUCTURE.md rewrite, 16 files got //! docs Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
//! Chat list panel: search box, chat items, and user online status.
|
||||
|
||||
use crate::app::App;
|
||||
use crate::app::methods::{compose::ComposeMethods, search::SearchMethods};
|
||||
use crate::tdlib::TdClientTrait;
|
||||
use crate::tdlib::UserOnlineStatus;
|
||||
use crate::ui::components;
|
||||
@@ -68,55 +71,16 @@ pub fn render<T: TdClientTrait>(f: &mut Frame, area: Rect, app: &mut App<T>) {
|
||||
|
||||
f.render_stateful_widget(chats_list, chat_chunks[1], &mut app.chat_list_state);
|
||||
|
||||
// User status - показываем статус выбранного чата
|
||||
let (status_text, status_color) = if let Some(chat_id) = app.selected_chat_id {
|
||||
match app.td_client.get_user_status_by_chat_id(chat_id) {
|
||||
Some(UserOnlineStatus::Online) => ("● онлайн".to_string(), Color::Green),
|
||||
Some(UserOnlineStatus::Recently) => ("был(а) недавно".to_string(), Color::Yellow),
|
||||
Some(UserOnlineStatus::Offline(was_online)) => {
|
||||
let formatted = format_was_online(*was_online);
|
||||
(formatted, Color::Gray)
|
||||
}
|
||||
Some(UserOnlineStatus::LastWeek) => {
|
||||
("был(а) на этой неделе".to_string(), Color::DarkGray)
|
||||
}
|
||||
Some(UserOnlineStatus::LastMonth) => {
|
||||
("был(а) в этом месяце".to_string(), Color::DarkGray)
|
||||
}
|
||||
Some(UserOnlineStatus::LongTimeAgo) => ("был(а) давно".to_string(), Color::DarkGray),
|
||||
None => ("".to_string(), Color::DarkGray), // Для групп/каналов
|
||||
}
|
||||
// User status - показываем статус выбранного или выделенного чата
|
||||
let status_chat_id = if app.selected_chat_id.is_some() {
|
||||
app.selected_chat_id
|
||||
} else {
|
||||
// Показываем статус выделенного в списке чата
|
||||
let filtered = app.get_filtered_chats();
|
||||
if let Some(i) = app.chat_list_state.selected() {
|
||||
if let Some(chat) = filtered.get(i) {
|
||||
match app.td_client.get_user_status_by_chat_id(chat.id) {
|
||||
Some(UserOnlineStatus::Online) => ("● онлайн".to_string(), Color::Green),
|
||||
Some(UserOnlineStatus::Recently) => {
|
||||
("был(а) недавно".to_string(), Color::Yellow)
|
||||
}
|
||||
Some(UserOnlineStatus::Offline(was_online)) => {
|
||||
let formatted = format_was_online(*was_online);
|
||||
(formatted, Color::Gray)
|
||||
}
|
||||
Some(UserOnlineStatus::LastWeek) => {
|
||||
("был(а) на этой неделе".to_string(), Color::DarkGray)
|
||||
}
|
||||
Some(UserOnlineStatus::LastMonth) => {
|
||||
("был(а) в этом месяце".to_string(), Color::DarkGray)
|
||||
}
|
||||
Some(UserOnlineStatus::LongTimeAgo) => {
|
||||
("был(а) давно".to_string(), Color::DarkGray)
|
||||
}
|
||||
None => ("".to_string(), Color::DarkGray),
|
||||
}
|
||||
} else {
|
||||
("".to_string(), Color::DarkGray)
|
||||
}
|
||||
} else {
|
||||
("".to_string(), Color::DarkGray)
|
||||
}
|
||||
app.chat_list_state.selected().and_then(|i| filtered.get(i).map(|c| c.id))
|
||||
};
|
||||
let (status_text, status_color) = match status_chat_id {
|
||||
Some(chat_id) => format_user_status(app.td_client.get_user_status_by_chat_id(chat_id)),
|
||||
None => ("".to_string(), Color::DarkGray),
|
||||
};
|
||||
|
||||
let status = Paragraph::new(status_text)
|
||||
@@ -125,7 +89,17 @@ pub fn render<T: TdClientTrait>(f: &mut Frame, area: Rect, app: &mut App<T>) {
|
||||
f.render_widget(status, chat_chunks[2]);
|
||||
}
|
||||
|
||||
/// Форматирование времени "был(а) в ..."
|
||||
fn format_was_online(timestamp: i32) -> String {
|
||||
crate::utils::format_was_online(timestamp)
|
||||
/// Форматирует статус пользователя для отображения в статус-баре
|
||||
fn format_user_status(status: Option<&UserOnlineStatus>) -> (String, Color) {
|
||||
match status {
|
||||
Some(UserOnlineStatus::Online) => ("● онлайн".to_string(), Color::Green),
|
||||
Some(UserOnlineStatus::Recently) => ("был(а) недавно".to_string(), Color::Yellow),
|
||||
Some(UserOnlineStatus::Offline(was_online)) => {
|
||||
(crate::utils::format_was_online(*was_online), Color::Gray)
|
||||
}
|
||||
Some(UserOnlineStatus::LastWeek) => ("был(а) на этой неделе".to_string(), Color::DarkGray),
|
||||
Some(UserOnlineStatus::LastMonth) => ("был(а) в этом месяце".to_string(), Color::DarkGray),
|
||||
Some(UserOnlineStatus::LongTimeAgo) => ("был(а) давно".to_string(), Color::DarkGray),
|
||||
None => ("".to_string(), Color::DarkGray),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user