Currently, GetHomePosts computes the home posts (including all followed posts) each time it is called. This is necessary because we want to call it with QEval (no gas fee) which can't update the realm data to save the result. But this is not scalable. This PR solves the problem by saving the state of the home posts. This is returned by GetHomePosts, but we add a separate RefreshHomePosts which is requires gas and adds the followed posts since the last call.
In a first minor commit, fix comments because the type Post.id should be PostID
In UserPosts, add the avl.Tree homePosts which saves the state of the home posts. In GetHomePosts, simply return this avl.Tree.
Update RenderUserPosts to use the current state of homePosts (if viewing the home feed). Also add a helper link to for "refresh".
In AddThread and AddRepostTo, add the new post to homePosts at the same time that we add to threads. This way, the home posts at least have the user's own posts without needing to call RefreshHomePosts.
Rename addFollowedPosts to refreshHomePosts. In UserPosts, add lastRefreshId and use it to only refresh followed posts since the last call to refreshHomePosts.
In FollowingInfo, add startedPostsCtr. Use this in refreshHomePosts to only add followed posts after started following.
Add the public function RefreshHomePosts which returns the new size of the home posts. An app can call this, and if the number of posts has increased then the app should refresh the display of the home feed.
Currently,
GetHomePosts
computes the home posts (including all followed posts) each time it is called. This is necessary because we want to call it with QEval (no gas fee) which can't update the realm data to save the result. But this is not scalable. This PR solves the problem by saving the state of the home posts. This is returned byGetHomePosts
, but we add a separateRefreshHomePosts
which is requires gas and adds the followed posts since the last call.Post.id
should bePostID
UserPosts
, add the avl.TreehomePosts
which saves the state of the home posts. InGetHomePosts
, simply return this avl.Tree.RenderUserPosts
to use the current state ofhomePosts
(if viewing the home feed). Also add a helper link to for "refresh".AddThread
andAddRepostTo
, add the new post tohomePosts
at the same time that we add tothreads
. This way, the home posts at least have the user's own posts without needing to callRefreshHomePosts
.addFollowedPosts
torefreshHomePosts
. InUserPosts
, addlastRefreshId
and use it to only refresh followed posts since the last call torefreshHomePosts
.FollowingInfo
, addstartedPostsCtr
. Use this inrefreshHomePosts
to only add followed posts after started following.RefreshHomePosts
which returns the new size of the home posts. An app can call this, and if the number of posts has increased then the app should refresh the display of the home feed.