Request about pages before posts
This commit is contained in:
parent
373ce55203
commit
078d6fe25b
@ -34,6 +34,9 @@ pub async fn page(req: HttpRequest) -> HttpResponse {
|
|||||||
.to_string();
|
.to_string();
|
||||||
let sort = req.match_info().get("sort").unwrap_or("hot").to_string();
|
let sort = req.match_info().get("sort").unwrap_or("hot").to_string();
|
||||||
|
|
||||||
|
match fetch_posts(&path, String::new()).await {
|
||||||
|
Ok((posts, after)) => {
|
||||||
|
// If you can get subreddit posts, also request subreddit metadata
|
||||||
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('+') {
|
||||||
@ -45,8 +48,6 @@ pub async fn page(req: HttpRequest) -> HttpResponse {
|
|||||||
Subreddit::default()
|
Subreddit::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
match fetch_posts(&path, String::new()).await {
|
|
||||||
Ok((posts, after)) => {
|
|
||||||
let s = SubredditTemplate {
|
let s = SubredditTemplate {
|
||||||
sub,
|
sub,
|
||||||
posts,
|
posts,
|
||||||
|
@ -24,12 +24,14 @@ pub async fn profile(req: HttpRequest) -> HttpResponse {
|
|||||||
let sort = param(&path, "sort");
|
let sort = param(&path, "sort");
|
||||||
let username = req.match_info().get("username").unwrap_or("").to_string();
|
let username = req.match_info().get("username").unwrap_or("").to_string();
|
||||||
|
|
||||||
// Request user profile data and user posts/comments from Reddit
|
// Request user posts/comments from Reddit
|
||||||
let user = user(&username).await.unwrap_or_default();
|
|
||||||
let posts = fetch_posts(&path, "Comment".to_string()).await;
|
let posts = fetch_posts(&path, "Comment".to_string()).await;
|
||||||
|
|
||||||
match posts {
|
match posts {
|
||||||
Ok((posts, after)) => {
|
Ok((posts, after)) => {
|
||||||
|
// If you can get user posts, also request user data
|
||||||
|
let user = user(&username).await.unwrap_or_default();
|
||||||
|
|
||||||
let s = UserTemplate {
|
let s = UserTemplate {
|
||||||
user,
|
user,
|
||||||
posts,
|
posts,
|
||||||
|
Loading…
Reference in New Issue
Block a user