summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThang Pham <phamducthang1234@gmail.com>2021-12-04 23:54:53 -0500
committerThang Pham <phamducthang1234@gmail.com>2021-12-04 23:54:53 -0500
commit3085b76390dec667877f1b7b0e443301287d83c4 (patch)
treebce4500cd7c568af4d19db2eee48e4fab97735e5
parent37da5a07f54104700afa3f05432b7d234a0c6635 (diff)
fix clippy errors, decode html for story's title
-rw-r--r--hackernews_tui/src/client/parser.rs13
-rw-r--r--hackernews_tui/src/config/keybindings.rs26
2 files changed, 3 insertions, 36 deletions
diff --git a/hackernews_tui/src/client/parser.rs b/hackernews_tui/src/client/parser.rs
index c2a6ae7..c5ec861 100644
--- a/hackernews_tui/src/client/parser.rs
+++ b/hackernews_tui/src/client/parser.rs
@@ -37,8 +37,6 @@ where
#[serde(rename_all(deserialize = "camelCase"))]
struct MatchResult {
value: String,
- #[serde(default)]
- matched_words: Vec<String>,
}
#[derive(Debug, Deserialize)]
@@ -56,9 +54,6 @@ pub struct StoryResponse {
#[serde(deserialize_with = "parse_id")]
id: u32,
- #[serde(default)]
- children: Vec<CommentResponse>,
-
title: Option<String>,
author: Option<String>,
url: Option<String>,
@@ -89,12 +84,6 @@ pub struct HNStoryResponse {
/// CommentResponse represents the comment data received from HN_ALGOLIA APIs
pub struct CommentResponse {
id: u32,
- #[serde(default)]
- #[serde(deserialize_with = "parse_null_default")]
- parent_id: u32,
- #[serde(default)]
- #[serde(deserialize_with = "parse_null_default")]
- story_id: u32,
#[serde(default)]
children: Vec<CommentResponse>,
@@ -174,7 +163,7 @@ impl From<StoryResponse> for Story {
// and its title field is not none,
let highlight_result_raw = s.highlight_result.unwrap();
let highlight_result = HighlightResult {
- title: highlight_result_raw.title.unwrap().value,
+ title: decode_html(&highlight_result_raw.title.unwrap().value),
url: match highlight_result_raw.url {
None => String::new(),
Some(url) => url.value,
diff --git a/hackernews_tui/src/config/keybindings.rs b/hackernews_tui/src/config/keybindings.rs
index f5a7983..c9a8789 100644
--- a/hackernews_tui/src/config/keybindings.rs
+++ b/hackernews_tui/src/config/keybindings.rs
@@ -3,7 +3,7 @@ use config_parser2::*;
use cursive::event::{self, Event, EventTrigger};
use serde::{de, Deserialize, Deserializer};
-#[derive(Debug, Clone, Deserialize, ConfigParse)]
+#[derive(Default, Debug, Clone, Deserialize, ConfigParse)]
pub struct KeyMap {
pub custom_keymap: CustomKeyMap,
pub edit_keymap: EditKeyMap,
@@ -14,20 +14,6 @@ pub struct KeyMap {
pub article_view_keymap: ArticleViewKeyMap,
}
-impl Default for KeyMap {
- fn default() -> Self {
- KeyMap {
- custom_keymap: CustomKeyMap::default(),
- edit_keymap: EditKeyMap::default(),
- global_keymap: GlobalKeyMap::default(),
- story_view_keymap: StoryViewKeyMap::default(),
- search_view_keymap: SearchViewKeyMap::default(),
- comment_view_keymap: CommentViewKeyMap::default(),
- article_view_keymap: ArticleViewKeyMap::default(),
- }
- }
-}
-
#[derive(Debug, Clone, Deserialize)]
pub struct CustomViewNavigation {
pub key: Key,
@@ -36,21 +22,13 @@ pub struct CustomViewNavigation {
pub numeric_filters: client::StoryNumericFilters,
}
-#[derive(Debug, Clone, Deserialize)]
+#[derive(Default, Debug, Clone, Deserialize)]
pub struct CustomKeyMap {
pub custom_view_navigation: Vec<CustomViewNavigation>,
}
config_parser_impl!(CustomKeyMap);
-impl Default for CustomKeyMap {
- fn default() -> Self {
- CustomKeyMap {
- custom_view_navigation: vec![],
- }
- }
-}
-
#[derive(Debug, Clone, Deserialize, ConfigParse)]
pub struct EditKeyMap {
pub move_cursor_left: Key,