-
-
Notifications
You must be signed in to change notification settings - Fork 885
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add user setting to auto-mark fetched posts as read. #5160
Conversation
- Rather than apps collecting up viewed posts ids, and sending many mark as read requests, users can now turn this setting on, and any results from /post/list will be auto-marked as read. - Fixes #5144
PostRead::mark_as_read(pool, HashSet::from([post_id]), person_id) | ||
.await | ||
.with_lemmy_type(LemmyErrorType::CouldntMarkPostAsRead)?; | ||
Ok(()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of these changes are boilerplate, because I've gotten rid of this pointless wrapper function, by having PostRead::mark_as_read
return the correct LemmyError.
crates/api/src/post/mark_read.rs
Outdated
|
||
#[tracing::instrument(skip(context))] | ||
pub async fn mark_post_as_read( | ||
data: Json<MarkPostAsRead>, | ||
context: Data<LemmyContext>, | ||
local_user_view: LocalUserView, | ||
) -> LemmyResult<Json<SuccessResponse>> { | ||
let post_ids = HashSet::from_iter(data.post_ids.clone()); | ||
let post_ids = &data.post_ids; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got rid of all these fairly pointless HashSets (a way to enforce uniqueness of post ids to be marked as read).
Since we're no longer allowing vectors of marked read post ids via the API, and only through code, these seemed redundant. Also postgres can handle in
queries with the same ID with no problem anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this function is unused now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've removed that now in other PRs.
Instead of a user setting, how about a parameter |
I'll add an override there then also, similar to |
Should we get rid of @EricBAndrews Please have a look at this. |
We still need mark_read, because this setting is optional (and default false), so most users will still need to explicitly mark posts in their feed as read if they don't want to click into them. #5043 will change the |
This feature unfortunately does not solve the use case that batch marking enables, namely marking read on scroll. Mlem fetches in pages of 50, and preemptively fetches the next page when the user is ~10 posts from the bottom. This means that up to 60 posts could be marked as read without the user ever seeing them (e.g., if they close the app right after a load), which given the relatively low daily post volume on an average subscribed feed means a user might miss significant blocks of content and therefore have an artificially deflated sense of the activity level on Lemmy. Even on a reduced page size of 20, it's still expected to leave 15 posts erroneously marked as read every time the feed is closed. For this reason I would not utilize this feature to support mark read on scroll, and would default instead to sending individual requests per post. The rate limit of 180/min should be basically fine for standard use cases, though in the spirit of efficient engineering I would prefer to avoid such an implementation. |
crates/api_common/src/post.rs
Outdated
@@ -108,6 +108,9 @@ pub struct GetPosts { | |||
/// If true, then show the nsfw posts (even if your user setting is to hide them) | |||
#[cfg_attr(feature = "full", ts(optional))] | |||
pub show_nsfw: Option<bool>, | |||
/// Whether to automatically mark fetched posts as read. | |||
#[cfg_attr(feature = "full", ts(optional))] | |||
pub auto_mark_fetched_posts_as_read: Option<bool>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be changed to mark_as_read
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
K fixed.
You could still batch read posts on the client side, and then call |
In that case I think I'll need to add back in a batch I'll do that in a different PR tho, because I could still see this setting being useful, if the fetch sizes are small enough for a given client. Also keep in mind this setting is default off, so it won't actually do any marking by default.
This wouldn't be possible because they need a subset of the posts that come back from post_list. IE if they've fetched 50 posts, they would only want to mark the 10 or so that can currently be viewed. For cases where the batch size is really large, we've no choice but to add back in a |
If youre adding the endpoint for marking multiple posts as read, then clients should use that one to be explicit about it. This approach will lead to unexpected behaviour as explained by @EricBAndrews, so we should close this PR. |
I don't think this should be closed, it'd still be a useful feature to have, as long as the fetch size is small enough. It'd especially be useful for non-endless-scrolling clients. This is also default off. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have the same concerns as @EricBAndrews on this proposal for Voyager app.
I am opposed to this PR because this setting only makes sense on paged layouts (page 1, page 2, page 3) where page directly corresponds to the request that will be made. This isn't true for infinite scrolling.
So why are you opposed to this for paged layouts also? Not all apps do infinite scrolling. Also this is entirely optional and default off. Are you opposed to optional features that some apps might find useful, but not yours specifically? |
Hi @dessalines thanks for your reply.
I am opposed to this for paged layouts because it breaking infinite scroll use cases:
To be clear, this is NOT entirely optional. If a user turns it on, it WILL break custom mark as read logic for mark-as-read-while-infinite-scrolling apps, which creates problems because many times a user will turn it on in lemmy-ui settings, because they want it on for lemmy-ui but they are NOT expecting it to affect Voyager, and then complaining to me that Voyager is broken. This same issue occured with the "Hide Read Posts" setting until #4846 was introduced (thanks for adding that). Speaking of #4846, this brings me to another option that would address both of our use cases: an override of the functionality in this PR per request. Add This could probably be added to this PR. |
The override is already included in this PR, you'll just pass false to that field in list_posts. |
My apologies, I did not read the PR close enough! (Or maybe I read an old commit accidentally? It has been a long week...) That fully addresses my concern then! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still need to address my previous comments, otherwise looks okay.
* Removing a few SuccessResponses for PostHide and MarkPostAsRead. - This also removes the pointless multiple post_ids. These can be done as individual calls on the front end anyway. - Fixes #4755 * Fixing federation tests. * Upgrading lemmy-js-client deps. * Add ability to mark several posts as read. Context: - #5043 - #4755 - #5160 * Fix ntfy to notify on success builds also. * Addressing PR comments.
* Removing a few SuccessResponses for PostHide and MarkPostAsRead. - This also removes the pointless multiple post_ids. These can be done as individual calls on the front end anyway. - Fixes #4755 * Fixing federation tests. * Upgrading lemmy-js-client deps. * Add ability to mark several posts as read. Context: - #5043 - #4755 - #5160 * Simplifying forms. * Fixing forms. * Cleanup post action forms by using derive_new defaults. - Fixes #5195 * Fix ntfy to notify on success builds also. * Removing pointless naive_now function. * Running taplo fmt.
list_posts
) as read. #5144