diff --git a/src/search.rs b/src/search.rs index 55f26a7..62b555d 100644 --- a/src/search.rs +++ b/src/search.rs @@ -1,5 +1,5 @@ // CRATES -use crate::utils::{error, fetch_posts, param, prefs, request, val, Post, Preferences, cookie}; +use crate::utils::{cookie, error, fetch_posts, param, prefs, request, val, Post, Preferences}; use actix_web::{HttpRequest, HttpResponse}; use askama::Template; diff --git a/src/subreddit.rs b/src/subreddit.rs index ea57322..52bcc34 100644 --- a/src/subreddit.rs +++ b/src/subreddit.rs @@ -98,7 +98,7 @@ async fn subreddit(sub: &str) -> Result { let active: i64 = res["data"]["accounts_active"].as_u64().unwrap_or_default() as i64; // Fetch subreddit icon either from the community_icon or icon_img value - let community_icon: &str = res["data"]["community_icon"].as_str().unwrap_or("").split('?').collect::>()[0]; + let community_icon: &str = res["data"]["community_icon"].as_str().map_or("", |s| s.split('?').collect::>()[0]); let icon = if community_icon.is_empty() { val(&res, "icon_img") } else { community_icon.to_string() }; let sub = Subreddit { diff --git a/src/utils.rs b/src/utils.rs index 0d32c03..9d6db88 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -286,7 +286,7 @@ pub fn time(created: f64) -> (String, String) { // val() function used to parse JSON from Reddit APIs pub fn val(j: &Value, k: &str) -> String { - String::from(j["data"][k].as_str().unwrap_or_default()) + j["data"][k].as_str().unwrap_or_default().to_string() } // Fetch posts of a user or subreddit and return a vector of posts and the "after" value diff --git a/static/style.css b/static/style.css index 7f2bfa4..6c2f914 100644 --- a/static/style.css +++ b/static/style.css @@ -460,7 +460,7 @@ a.search_subreddit:hover { } .post_score { - padding-top: 20px; + padding-top: 16px; font-size: 13px; font-weight: bold; text-align: end; @@ -476,7 +476,7 @@ a.search_subreddit:hover { } .post_header { - margin: 20px 20px 5px 20px; + margin: 15px 20px 5px 15px; grid-area: post_header; } @@ -487,7 +487,7 @@ a.search_subreddit:hover { .post_title { font-size: 16px; line-height: 1.5; - margin: 5px 20px; + margin: 5px 15px; grid-area: post_title; } @@ -548,7 +548,7 @@ a.search_subreddit:hover { .post_body { opacity: 0.9; font-weight: normal; - margin: 5px 20px; + margin: 5px 15px; grid-area: post_body; } @@ -558,7 +558,7 @@ a.search_subreddit:hover { opacity: 0.5; font-size: 14px; grid-area: post_footer; - margin: 5px 20px 20px 20px; + margin: 5px 20px 15px 15px; } .post_comments { @@ -925,20 +925,13 @@ td, th { } .post_score { - background-color: unset; - margin: 5px 0px 20px 20px; + margin: 5px 0px 20px 15px; padding: 0; } - .compact .post_score { - background-color: unset; - margin: 2.5px 0px 15px 15px; - padding: 0; - font-size: 14px; - } + .compact .post_score { padding: 0; } .post_score::before { content: "↑" } - .post:hover > .post_score { background: unset; } .post_header { font-size: 14px; } .post_footer { margin-left: 15px; }