[PR #74] [MERGED] Code refactor and cleanup part I #87

Closed
opened 2026-03-14 12:31:29 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/aome510/hackernews-TUI/pull/74
Author: @aome510
Created: 5/7/2022
Status: Merged
Merged: 5/8/2022
Merged by: @aome510

Base: mainHead: 05-07-22/code-refactor-and-cleanup


📝 Commits (10+)

  • b18c5c2 try to remove redudant clone(), minor refactor code structure
  • a1bc032 use into_par_iter when parsing stories
  • 3946ee3 add HTMLParsedResult
  • 3eb84d5 refactor article parse functions
  • 0196751 minor wording changes
  • 0e7b9e0 move the tab-to-spaces code to HNClient::get_article function
  • aa47eb2 wip rewrite async_view using result_view::ResultView
  • a71f047 rewrite async_view using new ResultView
  • 2404bf5 cleanup formatting
  • a24d233 add more code documents

📊 Changes

14 files changed (+436 additions, -379 deletions)

View changed files

📝 hackernews_tui/src/client/mod.rs (+20 -17)
📝 hackernews_tui/src/client/parser.rs (+244 -177)
📝 hackernews_tui/src/config/keybindings.rs (+4 -4)
📝 hackernews_tui/src/view/article_view.rs (+18 -16)
📝 hackernews_tui/src/view/async_view.rs (+29 -47)
📝 hackernews_tui/src/view/comment_view.rs (+0 -4)
hackernews_tui/src/view/error_view.rs (+0 -56)
📝 hackernews_tui/src/view/fn_view_wrapper.rs (+6 -9)
📝 hackernews_tui/src/view/mod.rs (+1 -1)
hackernews_tui/src/view/result_view.rs (+70 -0)
📝 hackernews_tui/src/view/search_view.rs (+11 -14)
📝 hackernews_tui/src/view/story_view.rs (+32 -25)
📝 hackernews_tui/src/view/text_view.rs (+0 -8)
📝 hackernews_tui/src/view/utils.rs (+1 -1)

📄 Description

Brief description of changes

  • refactored view::async_view codes
    • added ResultView, modified ErrorView
    • used anyhow::Context to decorate the encountered error when constructing async views
  • replaced view::error_view module with view::result_view
  • refactored parse functions in client::parser
    • added new structs to represent parsed results/ arguments
    • cleanup code, updated documents
  • removed Article::parsed_content, replaced Article::links with ArticleView::links
  • removed redundant clones

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/aome510/hackernews-TUI/pull/74 **Author:** [@aome510](https://github.com/aome510) **Created:** 5/7/2022 **Status:** ✅ Merged **Merged:** 5/8/2022 **Merged by:** [@aome510](https://github.com/aome510) **Base:** `main` ← **Head:** `05-07-22/code-refactor-and-cleanup` --- ### 📝 Commits (10+) - [`b18c5c2`](https://github.com/aome510/hackernews-TUI/commit/b18c5c20354e7712aca95dc52091f79330699024) try to remove redudant `clone()`, minor refactor code structure - [`a1bc032`](https://github.com/aome510/hackernews-TUI/commit/a1bc03279d1538ba1c9e9e62304ca1a2f656388b) use `into_par_iter` when parsing stories - [`3946ee3`](https://github.com/aome510/hackernews-TUI/commit/3946ee35db9d77e2581a5894d786ae7cbf851092) add `HTMLParsedResult` - [`3eb84d5`](https://github.com/aome510/hackernews-TUI/commit/3eb84d518b3ca80ef0b950cc49aa4c8fa5e9719b) refactor article parse functions - [`0196751`](https://github.com/aome510/hackernews-TUI/commit/019675143eb8fb247460ee305b0e3e3660e8e15d) minor wording changes - [`0e7b9e0`](https://github.com/aome510/hackernews-TUI/commit/0e7b9e08cd3f9cedd9d009bb4d05ec3e66b35fcf) move the tab-to-spaces code to `HNClient::get_article` function - [`aa47eb2`](https://github.com/aome510/hackernews-TUI/commit/aa47eb2572d38ef005ceff057290b6a55ea916db) wip rewrite `async_view` using `result_view::ResultView` - [`a71f047`](https://github.com/aome510/hackernews-TUI/commit/a71f047f68acec8686ab7b7d89e506a996284d6c) rewrite `async_view` using new `ResultView` - [`2404bf5`](https://github.com/aome510/hackernews-TUI/commit/2404bf5262df9c2d6a565bf3053559a992c566a0) cleanup formatting - [`a24d233`](https://github.com/aome510/hackernews-TUI/commit/a24d233fd30f0422d6d8ec855f516cc92e6d5f32) add more code documents ### 📊 Changes **14 files changed** (+436 additions, -379 deletions) <details> <summary>View changed files</summary> 📝 `hackernews_tui/src/client/mod.rs` (+20 -17) 📝 `hackernews_tui/src/client/parser.rs` (+244 -177) 📝 `hackernews_tui/src/config/keybindings.rs` (+4 -4) 📝 `hackernews_tui/src/view/article_view.rs` (+18 -16) 📝 `hackernews_tui/src/view/async_view.rs` (+29 -47) 📝 `hackernews_tui/src/view/comment_view.rs` (+0 -4) ➖ `hackernews_tui/src/view/error_view.rs` (+0 -56) 📝 `hackernews_tui/src/view/fn_view_wrapper.rs` (+6 -9) 📝 `hackernews_tui/src/view/mod.rs` (+1 -1) ➕ `hackernews_tui/src/view/result_view.rs` (+70 -0) 📝 `hackernews_tui/src/view/search_view.rs` (+11 -14) 📝 `hackernews_tui/src/view/story_view.rs` (+32 -25) 📝 `hackernews_tui/src/view/text_view.rs` (+0 -8) 📝 `hackernews_tui/src/view/utils.rs` (+1 -1) </details> ### 📄 Description ## Brief description of changes - refactored `view::async_view` codes + added `ResultView`, modified `ErrorView` + used `anyhow::Context` to decorate the encountered error when constructing async views - replaced `view::error_view` module with `view::result_view` - refactored parse functions in `client::parser` + added new structs to represent parsed results/ arguments + cleanup code, updated documents - removed `Article::parsed_content`, replaced `Article::links` with `ArticleView::links` - removed redundant `clones` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-14 12:31:29 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hackernews-TUI#87
No description provided.