refactor: improve code quality and consistency
Comprehensive code audit addressing naming consistency, dead code removal, and documentation improvements across the entire codebase. - Rename panel_pages.rs → pages_panel.rs for consistent naming - Unify view functions: all panels now use view() convention - Rename header_start/end() → start/end() for brevity - Update all imports and references - Remove Rotation::from_degrees() (only 4 fixed states needed) - Remove TransformState::identity() and is_identity() (Default suffices) - Remove duplicate convenience methods from RasterDocument, VectorDocument, PortableDocument (rotate_cw/ccw, flip_horizontal/vertical) - Remove unused imports and constants (ROTATION_STEP, FULL_ROTATION) - Rename constants: PDF_RENDER_SCALE → PDF_RENDER_QUALITY, PDF_THUMBNAIL_SCALE → PDF_THUMBNAIL_SIZE - Add comprehensive trait documentation explaining type erasure pattern - Document why large enum variants are acceptable - Add #[allow(dead_code)] with explanations for trait API types - Improve all constant and config comments - Collapse nested if statements using Rust 2024 let-chains - Replace single-arm match with if-let - Introduce StateChangeCallback<Message> type alias - Apply clippy auto-fixes for better code style
This commit is contained in:
parent
0e31b146a3
commit
9399a008c4
19 changed files with 744 additions and 418 deletions
|
|
@ -39,17 +39,16 @@ pub fn update(model: &mut AppModel, msg: &AppMessage, config: &AppConfig) -> Upd
|
|||
}
|
||||
|
||||
AppMessage::GotoPage(page) => {
|
||||
if let Some(doc) = &mut model.document {
|
||||
if let Err(e) = doc.goto_page(*page) {
|
||||
if let Some(doc) = &mut model.document
|
||||
&& let Err(e) = doc.go_to_page(*page) {
|
||||
log::error!("Failed to navigate to page {}: {}", page, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Thumbnail generation -------------------------------------------------
|
||||
AppMessage::GenerateThumbnailPage(page) => {
|
||||
if let Some(doc) = &mut model.document {
|
||||
if let Some(next_page) = doc.generate_thumbnail_page(*page) {
|
||||
if let Some(doc) = &mut model.document
|
||||
&& let Some(next_page) = doc.generate_thumbnail_page(*page) {
|
||||
return UpdateResult::Task(Task::batch([
|
||||
Task::future(async move {
|
||||
Action::App(AppMessage::GenerateThumbnailPage(next_page))
|
||||
|
|
@ -57,7 +56,6 @@ pub fn update(model: &mut AppModel, msg: &AppMessage, config: &AppConfig) -> Upd
|
|||
Task::done(Action::App(AppMessage::RefreshView)),
|
||||
]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AppMessage::RefreshView => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue