mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-17 09:54:01 +00:00
Adding list_post request option to auto-mark as read.
This commit is contained in:
parent
bd0e68fb00
commit
3dbc33e68c
2 changed files with 7 additions and 2 deletions
|
@ -85,6 +85,8 @@ pub struct GetPosts {
|
|||
pub show_read: Option<bool>,
|
||||
/// If true, then show the nsfw posts (even if your user setting is to hide them)
|
||||
pub show_nsfw: Option<bool>,
|
||||
/// Whether to automatically mark fetched posts as read.
|
||||
pub auto_mark_fetched_posts_as_read: Option<bool>,
|
||||
pub page_cursor: Option<PaginationCursor>,
|
||||
}
|
||||
|
||||
|
|
|
@ -91,9 +91,12 @@ pub async fn list_posts(
|
|||
.await
|
||||
.with_lemmy_type(LemmyErrorType::CouldntGetPosts)?;
|
||||
|
||||
// If in their user settings, auto-mark fetched posts as read
|
||||
// If in their user settings (or as part of the API request), auto-mark fetched posts as read
|
||||
if let Some(local_user) = local_user {
|
||||
if local_user.auto_mark_fetched_posts_as_read {
|
||||
if data
|
||||
.auto_mark_fetched_posts_as_read
|
||||
.unwrap_or(local_user.auto_mark_fetched_posts_as_read)
|
||||
{
|
||||
let post_ids = posts.iter().map(|p| p.post.id).collect::<Vec<PostId>>();
|
||||
PostRead::mark_as_read(&mut context.pool(), &post_ids, local_user.person_id).await?;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue