Clean Subreddit struct
This commit is contained in:
parent
4d18dc0bb8
commit
6bbc90bc0d
@ -37,8 +37,10 @@ pub async fn page(req: HttpRequest) -> HttpResponse {
|
|||||||
let sub = if !sub_name.contains('+') && sub_name != "popular" && sub_name != "all" {
|
let sub = if !sub_name.contains('+') && sub_name != "popular" && sub_name != "all" {
|
||||||
subreddit(&sub_name).await.unwrap_or_default()
|
subreddit(&sub_name).await.unwrap_or_default()
|
||||||
} else if sub_name.contains('+') {
|
} else if sub_name.contains('+') {
|
||||||
let mut default = Subreddit::default();
|
Subreddit {
|
||||||
default.name = sub_name; default
|
name: sub_name,
|
||||||
|
..Subreddit::default()
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Subreddit::default()
|
Subreddit::default()
|
||||||
};
|
};
|
||||||
|
@ -170,7 +170,7 @@ pub async fn media(data: &serde_json::Value) -> (String, String) {
|
|||||||
} else if data["post_hint"].as_str().unwrap_or("") == "image" {
|
} else if data["post_hint"].as_str().unwrap_or("") == "image" {
|
||||||
post_type = "image";
|
post_type = "image";
|
||||||
format_url(data["preview"]["images"][0]["source"]["url"].as_str().unwrap_or_default().to_string())
|
format_url(data["preview"]["images"][0]["source"]["url"].as_str().unwrap_or_default().to_string())
|
||||||
} else if data["is_self"].as_bool().unwrap_or_default() {
|
} else if data["is_self"].as_bool().unwrap_or_default() {
|
||||||
post_type = "self";
|
post_type = "self";
|
||||||
data["permalink"].as_str().unwrap_or_default().to_string()
|
data["permalink"].as_str().unwrap_or_default().to_string()
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user