mirror of https://github.com/spikecodes/libreddit
Request about pages before posts
This commit is contained in:
parent
373ce55203
commit
078d6fe25b
|
@ -34,19 +34,20 @@ pub async fn page(req: HttpRequest) -> HttpResponse {
|
|||
.to_string();
|
||||
let sort = req.match_info().get("sort").unwrap_or("hot").to_string();
|
||||
|
||||
let sub = if !sub_name.contains('+') && sub_name != "popular" && sub_name != "all" {
|
||||
subreddit(&sub_name).await.unwrap_or_default()
|
||||
} else if sub_name.contains('+') {
|
||||
Subreddit {
|
||||
name: sub_name,
|
||||
..Subreddit::default()
|
||||
}
|
||||
} else {
|
||||
Subreddit::default()
|
||||
};
|
||||
|
||||
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" {
|
||||
subreddit(&sub_name).await.unwrap_or_default()
|
||||
} else if sub_name.contains('+') {
|
||||
Subreddit {
|
||||
name: sub_name,
|
||||
..Subreddit::default()
|
||||
}
|
||||
} else {
|
||||
Subreddit::default()
|
||||
};
|
||||
|
||||
let s = SubredditTemplate {
|
||||
sub,
|
||||
posts,
|
||||
|
|
|
@ -24,12 +24,14 @@ pub async fn profile(req: HttpRequest) -> HttpResponse {
|
|||
let sort = param(&path, "sort");
|
||||
let username = req.match_info().get("username").unwrap_or("").to_string();
|
||||
|
||||
// Request user profile data and user posts/comments from Reddit
|
||||
let user = user(&username).await.unwrap_or_default();
|
||||
// Request user posts/comments from Reddit
|
||||
let posts = fetch_posts(&path, "Comment".to_string()).await;
|
||||
|
||||
match posts {
|
||||
Ok((posts, after)) => {
|
||||
// If you can get user posts, also request user data
|
||||
let user = user(&username).await.unwrap_or_default();
|
||||
|
||||
let s = UserTemplate {
|
||||
user,
|
||||
posts,
|
||||
|
|
Loading…
Reference in New Issue