Skip to content
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 feature for mark read on scroll #1139

Merged
merged 20 commits into from
Mar 5, 2024

Conversation

Fmstrat
Copy link
Contributor

@Fmstrat Fmstrat commented Feb 19, 2024

Pull Request Description

Adds setting under General -> Feed for Mark Read On Scroll.

NOTE
This should be merged after #1137 as that PR is a minor change that also fixes CI. This PR also contains those changes as it was built off that branch.

Issue Being Fixed

N/a, but discussion here: #1138

Issue Number: 1138

Screenshots / Recordings

image

Checklist

  • Did you update CHANGELOG.md?
  • Did you use localized strings where applicable?
  • Did you add semanticLabels where applicable for accessibility?

@Fmstrat Fmstrat mentioned this pull request Feb 19, 2024
6 tasks
@Fmstrat
Copy link
Contributor Author

Fmstrat commented Feb 19, 2024

@micahmo You mentioned rebasing these changes to separate them from the Docker changes, however since the CI is broken until that PR is merged, it shohuld probably be done first. So I just left this as-is.

@Fmstrat
Copy link
Contributor Author

Fmstrat commented Feb 19, 2024

And this is the only repo I've worked on where the PR #s and the Issue #s are so close, crazy!

@micahmo
Copy link
Member

micahmo commented Feb 20, 2024

And this is the only repo I've worked on where the PR #s and the Issue #s are so close, crazy!

I always thought GitHub shared ID ranges for PRs and issues. Someone just opened a new issue and it's 1140. So I think the numbers will always be close. 😊

@hjiangsu
Copy link
Member

hjiangsu commented Feb 21, 2024

Sorry for the delay, and thanks for your work on this! I do have one discussion point that I'd like to bring up which may simplify the logic for determining which posts to mark as read.

There is this package: https://pub.dev/packages/visibility_detector which allows us to detect when a widget is visible or not. This might be a more robust solution for determining if the post has been scrolled past since it doesn't rely on touch events, and we can adjust the threshold at which the callback triggers based on visibleFraction.

Let me know your thoughts!

@Fmstrat
Copy link
Contributor Author

Fmstrat commented Feb 21, 2024

Oh good find. I will take a look later and see how it performs.

@Fmstrat
Copy link
Contributor Author

Fmstrat commented Feb 23, 2024

Forgot to post here last night, but I have a working version using VisiblityDetector that still takes advantage of future multi-mark-as-read in .19 when ready. Tested on my device last night and early this morning, and all seems good. So I will push this evening after I finish my normal day.

@Fmstrat
Copy link
Contributor Author

Fmstrat commented Feb 24, 2024

Ok, this should be ready now.

  • Visibility Detector required a bump to target SDK 34
  • It tracks the previously tapped index to stop it from marking read when scrolling backwards quickly from touching the bottom. It's not perfect, but it does the trick well enough.
    • Because there is no way to know if something is visible from scrolling up or down in native VisibilityDetector
  • Continues to support multiRead for when the .19 update is ready to be completed.

@micahmo
Copy link
Member

micahmo commented Feb 24, 2024

If it's ok, I'll review this after #1137 so the intended changes are more obvious. 😊

@Fmstrat
Copy link
Contributor Author

Fmstrat commented Feb 25, 2024

Found a small bug, will fix soon.

@Fmstrat
Copy link
Contributor Author

Fmstrat commented Feb 26, 2024

Ok, this one is good for sure now. This weekend I added in a check to ensure the scroll was moving down, that way it wouldn't accidentally mark as read from in the middle of the screen when scrolling back up.

@hjiangsu
Copy link
Member

Just released 0.2.9, so I'll start looking at the PR backlog soon. Thanks again for doing this @Fmstrat!

@Fmstrat
Copy link
Contributor Author

Fmstrat commented Feb 26, 2024

I should say I haven't done any device testing on my new change yet, will do that tonight.

@Fmstrat
Copy link
Contributor Author

Fmstrat commented Feb 28, 2024

I've been testing on a phone and tablet for the past day off and on, and things seem to be working cleanly after the bug fix.

@hjiangsu
Copy link
Member

#1137 has been merged in now. I'll review this once the merge conflicts are fixed!

Copy link
Member

@micahmo micahmo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't test the feature, but the code LGTM!

Comment on lines 228 to 229
// Give a slight delay to have the UI perform any navigation first
await Future.delayed(const Duration(milliseconds: 250));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this delay is needed for this use case.

Comment on lines 50 to 51
// TODO: Lemmy 0.19 support postIds in MarkPostAsRead
// Check what version the server is, and use that if we can
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check out the supportsFeature method in lemmy_client.dart if you want to make a version-specific call.

Copy link
Member

@hjiangsu hjiangsu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just left one comment! One thing I am concerned about is the number of API calls that might come from this feature.

I'm not quite sure if there are rate limits for mark as read action, so I'll leave it up for discussion whether or not we should reserve this feature for v0.19 to take advantage of the new API.

@@ -73,14 +73,16 @@ final class FeedItemActionedEvent extends FeedEvent {
/// If both are provided, [postId] will take precedence
final int? postId;

final List<int>? postIds;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add a small comment describing what this parameter is used for (e.g., If passed in, the [postAction] is applied to all the posts in the list)

@Fmstrat
Copy link
Contributor Author

Fmstrat commented Mar 1, 2024

I can say over the past week of use I haven't hit any rate limit issues, but that doesn't mean limits don't exist.

@hjiangsu
Copy link
Member

hjiangsu commented Mar 3, 2024

Hey! A little update - so I did a bit of testing on my device, and it feels like its a finicky sometimes (sometimes, it'll miss marking as read for some posts event after i scrolled for a bit)

I'll try to do some tweaks to see if maybe I can make it work a bit more fluidly for me if thats okay with you? I'll also add in logic to handle the 0.19 multi-read API (I'll keep the 0.18 logic since I haven't ran into rate limit issues either)

@Fmstrat
Copy link
Contributor Author

Fmstrat commented Mar 3, 2024

Oh definately, do what you will with it!

@hjiangsu
Copy link
Member

hjiangsu commented Mar 4, 2024

Alright, I did the following:

  • Added 0.19 functionality for multiple posts ids
  • Adjusted some of the logic to hopefully make mark as read more robust and added a debounce delay to slow down API requests (just in case)

All of the adjustments were made in this commit: fcc1737

@Fmstrat Could you try this out and let me know if this is working well for you? Thanks!

@hjiangsu
Copy link
Member

hjiangsu commented Mar 5, 2024

I'll go ahead an merge this in first, but let me know if you encounter any issues with implementation!

@hjiangsu hjiangsu merged commit b26f571 into thunder-app:develop Mar 5, 2024
1 check passed
@Offerel
Copy link

Offerel commented Mar 10, 2024

Is there an APK or a possible date somewhere when a beta version will be available?

@Fmstrat
Copy link
Contributor Author

Fmstrat commented Mar 10, 2024

@hjiangsu I'm not able to compile at the moment, so I can't check the changes on my devices. But given that and the above comment, any interest in setting up a nightly? https://stackoverflow.com/questions/63014786/how-to-schedule-a-github-actions-nightly-build-but-run-it-only-when-there-where

Fully understand if not.

@hjiangsu
Copy link
Member

Definitely! I was planning on setting up a nightly build within the next couple of days.

I'm currently building nightlies manually rather than automatically because I write up the release notes for them instead of generating the default GitHub changelog. This is so that I can provide more context into some of the changes and also mention notable features to test out for each nightly (although this might change in the future if there's too much overhead in doing this 😅).

@micahmo
Copy link
Member

micahmo commented Mar 10, 2024

Note that it is possible for GitHub actions to make "draft" releases (which are not public) to which you can attach the manual release notes and then publish. So it would remove all of the overhead except for the notes.

Speaking of which, we haven't been very good about manually updating CHANGELOG.md. Is that still valuable to you @hjiangsu? If so, we should be better about enforcing it for PRs. If not, we can remove that checkbox.

@hjiangsu
Copy link
Member

hjiangsu commented Mar 11, 2024

Note that it is possible for GitHub actions to make "draft" releases (which are not public) to which you can attach the manual release notes and then publish. So it would remove all of the overhead except for the notes.

Thats what I'm doing at the moment! I do wonder if there's a way to make a "template" release (similar to how you can make autogenerated changelogs in releases)

Speaking of which, we haven't been very good about manually updating CHANGELOG.md. Is that still valuable to you @hjiangsu?

Ahh yeah, I haven't been relying on CHANGELOG.md as much now because I try to make the commit messages for PRs the changelog if that makes sense. I have no preferences either way (whether we enforce it more or remove it)

@micahmo
Copy link
Member

micahmo commented Mar 11, 2024

Note that it is possible for GitHub actions to make "draft" releases (which are not public) to which you can attach the manual release notes and then publish. So it would remove all of the overhead except for the notes.

Thats what I'm doing at the moment! I do wonder if there's a way to make a "template" release (similar to how you can make autogenerated changelogs in releases)

I meant that we can create an automated GitHub Action (like our build and instance updater) that actually generates the release artifacts for you (apk/ipa), either on a schedule, or manually, or whatever you want. It can create the draft release with whatever contents you want (like a template) and then literally all you'd have to do is go in and fill out the info.

To make it even more fancy, you could have the release notes controlled by a file in the repo. Then you could push an update to that file, which would kick off the release and use the contents of that file as the contents of the release. Just some ideas!

@hjiangsu
Copy link
Member

Oh thats really cool! I realized that you can create release artifacts through GitHub Actions, but did not know you could create draft releases from it.

That might be something I look into then - I'll still have to find a way to coordinate making the associated Lemmy post, and publish it to Apple's TestFlight (could be done through fastlane if I set that up properly)

On another note, @Offerel, I just released a new nightly version https://github.com/thunder-app/thunder/releases/tag/0.3.0-1 which contains the mark as read on scroll. Feel free to test it out and let me know how it goes!

@Offerel
Copy link

Offerel commented Mar 11, 2024

Many thx. I think the work you're doing is great. It's really nice to see how wishes from the community are not only taken seriously, but also implemented sensibly. Thumbs up!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants