mirror of
https://github.com/redlib-org/redlib.git
synced 2025-05-14 14:02:50 +00:00
Fix Subreddit Icons
This commit is contained in:
parent
44d44a529c
commit
280e16bd7f
4 changed files with 19 additions and 14 deletions
|
@ -55,15 +55,9 @@ pub async fn render(sub_name: String, sort: Option<String>, ends: (Option<String
|
|||
.unwrap();
|
||||
Ok(HttpResponse::Ok().status(StatusCode::NOT_FOUND).content_type("text/html").body(s))
|
||||
} else {
|
||||
let mut sub = sub_result.unwrap();
|
||||
let sub = sub_result.unwrap();
|
||||
let items = items_result.unwrap();
|
||||
|
||||
sub.icon = if sub.icon != "" {
|
||||
format!(r#"<img class="subreddit_icon" src="{}">"#, sub.icon)
|
||||
} else {
|
||||
String::new()
|
||||
};
|
||||
|
||||
let s = SubredditTemplate {
|
||||
sub: sub,
|
||||
posts: items.0,
|
||||
|
@ -95,11 +89,18 @@ async fn subreddit(sub: &String) -> Result<Subreddit, &'static str> {
|
|||
let members = res["data"]["subscribers"].as_u64().unwrap_or(0);
|
||||
let active = res["data"]["accounts_active"].as_u64().unwrap_or(0);
|
||||
|
||||
let community_icon: &str = res["data"]["community_icon"].as_str().unwrap().split("?").collect::<Vec<&str>>()[0];
|
||||
let icon = if community_icon.is_empty() {
|
||||
val(&res, "icon_img").await
|
||||
} else {
|
||||
community_icon.to_string()
|
||||
};
|
||||
|
||||
let sub = Subreddit {
|
||||
name: val(&res, "display_name").await,
|
||||
title: val(&res, "title").await,
|
||||
description: val(&res, "public_description").await,
|
||||
icon: format_url(val(&res, "icon_img").await.as_str()).await,
|
||||
icon: format_url(icon).await,
|
||||
members: format_num(members.try_into().unwrap()),
|
||||
active: format_num(active.try_into().unwrap()),
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue