Pre-Flight checklist
Describe The Feature Request Below
Looking at PostListings.kt, it looks like we're currently passing up larger objects for actions, instead of forms. IE:
onUpvoteClick: (postView: PostView) -> Unit
We then have to do the logic of building the API form manually in a top-level component like HomePane.kt.
homeViewModel.likePost(
CreatePostLike(
post_id = postView.post.id,
score = newVote(postView.post_actions?.like_score ?: 0, VoteType.Upvote),
),
)
A better pattern from lemmy-ui, is simply to pass up the form itself, so that top-level components don't have to do any logic:
onUpvoteClick: (form: CreatePostLike) -> Unit
Then we can simply do viewModel.likePost(form), and there's no chance of any mistakes or manipulations.
Pre-Flight checklist
Describe The Feature Request Below
Looking at
PostListings.kt, it looks like we're currently passing up larger objects for actions, instead of forms. IE:onUpvoteClick: (postView: PostView) -> UnitWe then have to do the logic of building the API form manually in a top-level component like
HomePane.kt.A better pattern from lemmy-ui, is simply to pass up the form itself, so that top-level components don't have to do any logic:
onUpvoteClick: (form: CreatePostLike) -> UnitThen we can simply do
viewModel.likePost(form), and there's no chance of any mistakes or manipulations.