-
Notifications
You must be signed in to change notification settings - Fork 169
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
Mark as Read on Open and Scroll #1025
Conversation
Instead of passing that through the navigation as a JSONed string, pass the homeviewmodel to the post activity and only update that post. (I think it already does that in some places) |
# Conflicts: # app/src/main/java/com/jerboa/MainActivity.kt # app/src/main/java/com/jerboa/db/AppDB.kt # app/src/main/java/com/jerboa/model/HomeViewModel.kt # app/src/main/java/com/jerboa/model/PostViewModel.kt # app/src/main/java/com/jerboa/ui/components/community/CommunityActivity.kt # app/src/main/java/com/jerboa/ui/components/home/HomeActivity.kt # app/src/main/java/com/jerboa/ui/components/person/PersonProfileActivity.kt # app/src/main/java/com/jerboa/ui/components/post/PostActivity.kt # app/src/main/java/com/jerboa/ui/components/post/PostListing.kt # app/src/main/java/com/jerboa/ui/components/settings/lookandfeel/LookAndFeelActivity.kt
@MV-GH like so?
Won't that mark the post as read with the api twice? |
No i was thinking about |
@MV-GH Okay, I think I got it, not 100% sure if its correct though, if a user navigates back to home to quickly, I don't think it will update |
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.
Also, actually i think the viewmodel approach I said earlier, is not the way we should take this. We can open posts from many different locations. And this would only work with homeviewmodel. It also makes it a global and to make it work with the other viewmodels it would also make them a global. Instead I propose we should use the navController.ConsumeReturn
Where if you return from a postActivity to a postlisiting. You refresh that post you went to. You will probably have to add this in each relevant activity. Such as PersonProfile, Home and Community
app/src/main/java/com/jerboa/ui/components/settings/lookandfeel/LookAndFeelActivity.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/com/jerboa/ui/components/post/PostListings.kt
Outdated
Show resolved
Hide resolved
While I'm busy should I just do this for all activities that navigate to a post? |
Yes |
I'm not super familiar with android architecture, why do we have duplicate functions in each ViewModel, can't they be extracted to a common place? |
Such as? If you mean the nextPage and such yes they can be. See #807 |
Nevermind sorry, I was just putting it in the back stack too early |
Can you push what you have, I take a look when I have some time |
Sorry, nevermind. Updated my previous comment |
I'll take a look at this once the conflicts are fixed |
I've also noticed that voting on a post doesn't show on the home activity if you navigate back too quickly since the request hasn't been completed by the time the return is consumed 😢 |
I don't understand why it doesn't re-compose when the postsRes is updated in |
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.
LGTM but in the future please avoid reformatting code unrelated to your change.
# Conflicts: # app/schemas/com.jerboa.db.AppDB/22.json # app/src/main/java/com/jerboa/api/Http.kt # app/src/main/java/com/jerboa/db/AppDBMigrations.kt # app/src/main/java/com/jerboa/ui/components/community/CommunityActivity.kt # app/src/main/java/com/jerboa/ui/components/home/HomeActivity.kt # app/src/main/java/com/jerboa/ui/components/person/PersonProfileActivity.kt # app/src/main/java/com/jerboa/ui/components/post/PostListings.kt # app/src/main/res/values/strings.xml
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.
This changes are since that I have made account not nullable anymore, so now instead you have to check if it is Anon account or not
app/src/main/java/com/jerboa/ui/components/post/PostActivity.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/com/jerboa/ui/components/person/PersonProfileActivity.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/com/jerboa/ui/components/home/HomeActivity.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/com/jerboa/ui/components/community/CommunityActivity.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/com/jerboa/ui/components/post/PostActivity.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/com/jerboa/ui/components/person/PersonProfileActivity.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/com/jerboa/ui/components/home/HomeActivity.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/com/jerboa/ui/components/community/CommunityActivity.kt
Outdated
Show resolved
Hide resolved
I did some testing, and if you open a post and close it before it even gets to load and thus fire our markRead, and then open it again let it properly load and then go back you will see that the post in the feed does not turn read. That is because when you open it again and thus request the post again. The read is already true and it wont fire markRead and thus not the So what I think is happening is that as soon as you even request to load the post. It will automatically be set to read, by lemmy making our markRead changes unnecessary but I have not confirmed this yet. |
Alright just confirmed this with postman. If you open a unread post, you will get a response that is I'm thinking as soon as you click on a post it should mark it instantly as read in the feed (the feed itself updates the read). The problem is, what if you click on a post and it fails loading it. |
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 think the approach we should take is, just keep the addReturn were it is now but it should always do it if you are logged in. Even when the post is read=true
. The feed will only show it as read if the user sees the post. This will also prevent that previous issue where the post is not turning read in the feed if you open and close it quickly.
app/src/main/java/com/jerboa/ui/components/post/PostActivity.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/com/jerboa/ui/components/post/PostActivity.kt
Outdated
Show resolved
Hide resolved
Ah pipeline died, you can try |
Oh I wish. This is a windows laptop 😁 we use |
It does actually work in CMD and since PS 7 |
Addresses: #403, #535
Mark on scroll works beatifully:
Mark on open doesn't update the LazyColumn on Home. In fact, any update in PostActivity doesn't reflect on Home until refresh:
val read: MutableState = mutableStateOf(false)) seems to be the answer but GSON doesn't know how to deserialize MutableState 🤷♂️
Any advice would be appreciated