Replies: 1 comment
-
Now added a way to monitor the database, see how many posts are there and the database size (I chose MB as the unit but it seems to be too large so I will move to KB) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Checklist
Description
One pretty requested feature is being able to customize the limit on how many read posts can be stored on the database. Currently there is a limit of 500 read posts that can be stored.
Alternatives
No response
Additional context
I have been working on implementing an addition to the "Post History" settings which will allow you to customize the read posts limit (or get rid of it entirely). Here is a screenshot of how it looks:
I am also planning to add a text beneath it which displays the number of read posts stored in the database and how much space it takes up in the disk for those interested in monitoring it.
How important is this feature?
None
Anything else?
There is an issue though. Currently, while the app is running, the entire list of the read posts is read from the database and is handled on memory while the app is open. This wasn't an issue with the current limit of 500 read posts, but with an arbitrary limit this can cause problems which might lead to a slow experience or even crashes.
Solution
My solution to the problem is to move to a different system for handling the read posts while the app is open.
After looking a bit at the code, I noticed that the functions that ultimately ends up utilizing readPosts is the parsePostsSync (in ParsePost.Java) function which gets readPosts as a parameter. I propose passing a RedditDataRoomDatabase type to only get the posts that are needed (i.e the posts that are currently being paged) via query and mark them as read instead of going through the entire list.
We can do this by adding
to ReadPostDao and changing parsePostSync to:
This code will first get the relevant posts, and then query all the corresponding read posts from the DB using their IDs. The size of the read posts list will be optimal and will allow for the scaling of the read posts DB to arbitrary size.
I am looking for some assistance from someone who is familiar with the structure of the source code. How do you propose changing the rest of the code to stop using readPosts as a list? I see the list is created in PostFragment and is passed around as an argument between classes and functions until reaching parsePostsSync. Also are there any other functions that end up actually using readPosts other than parsePostsSync?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions