From a21df8ed8bde353033800e20659b7208deaa736a Mon Sep 17 00:00:00 2001 From: Dessalines Date: Mon, 2 Sep 2024 08:58:33 -0400 Subject: [PATCH] Showing scores in post listing like they were before. - Fixes #1627 --- app/src/main/java/com/jerboa/feat/Voting.kt | 6 +++--- .../com/jerboa/ui/components/common/VoteHelpers.kt | 14 +++++++++----- .../jerboa/ui/components/post/PostListingList.kt | 2 ++ 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/jerboa/feat/Voting.kt b/app/src/main/java/com/jerboa/feat/Voting.kt index 0a8bd1da4..493e51314 100644 --- a/app/src/main/java/com/jerboa/feat/Voting.kt +++ b/app/src/main/java/com/jerboa/feat/Voting.kt @@ -64,10 +64,10 @@ private fun scoreOrPctStr( ): String? = if (voteDisplayMode.upvote_percentage) { formatPercent(upvotePercent(upvotes, downvotes)) - } else if (!(voteDisplayMode.score && voteDisplayMode.upvotes && voteDisplayMode.downvotes)) { - null - } else { + } else if (voteDisplayMode.score || voteDisplayMode.upvotes || voteDisplayMode.downvotes) { score.toString() + } else { + null } fun LocalUserVoteDisplayMode.Companion.default(score: Boolean? = false) = diff --git a/app/src/main/java/com/jerboa/ui/components/common/VoteHelpers.kt b/app/src/main/java/com/jerboa/ui/components/common/VoteHelpers.kt index dc8db1fd1..012412e44 100644 --- a/app/src/main/java/com/jerboa/ui/components/common/VoteHelpers.kt +++ b/app/src/main/java/com/jerboa/ui/components/common/VoteHelpers.kt @@ -32,6 +32,7 @@ fun VoteGeneric( type: VoteType, onVoteClick: () -> Unit, account: Account, + hideScores: Boolean = false, ) { val iconAndColor = iconAndColor(type, instantScores) @@ -42,11 +43,14 @@ fun VoteGeneric( VoteType.Downvote -> instantScores.downvotes } - val hideScore = when (type) { - VoteType.Upvote -> !voteDisplayMode.upvotes - VoteType.Downvote -> !voteDisplayMode.downvotes - } && - !legacyScoresHidden(voteDisplayMode = voteDisplayMode) + val hideScore = hideScores || + ( + !legacyScoresHidden(voteDisplayMode = voteDisplayMode) && + when (type) { + VoteType.Upvote -> !voteDisplayMode.upvotes + VoteType.Downvote -> !voteDisplayMode.downvotes + } + ) val voteStr = if (votes > 0 && !hideScore) { votes.toString() diff --git a/app/src/main/java/com/jerboa/ui/components/post/PostListingList.kt b/app/src/main/java/com/jerboa/ui/components/post/PostListingList.kt index 7f269b3fb..e554f9d84 100644 --- a/app/src/main/java/com/jerboa/ui/components/post/PostListingList.kt +++ b/app/src/main/java/com/jerboa/ui/components/post/PostListingList.kt @@ -281,6 +281,7 @@ fun PostVotingTile( type = VoteType.Upvote, onVoteClick = onUpvoteClick, account = account, + hideScores = true, ) val scoreOrPctStr = instantScores.scoreOrPctStr(voteDisplayMode) @@ -306,6 +307,7 @@ fun PostVotingTile( type = VoteType.Downvote, onVoteClick = onDownvoteClick, account = account, + hideScores = true, ) } }