Skip to content

Commit

Permalink
Showing scores in post listing like they were before. (#1641)
Browse files Browse the repository at this point in the history
- Fixes #1627
  • Loading branch information
dessalines authored Sep 2, 2024
1 parent db816c9 commit 7e753bd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
6 changes: 3 additions & 3 deletions app/src/main/java/com/jerboa/feat/Voting.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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) =
Expand Down
14 changes: 9 additions & 5 deletions app/src/main/java/com/jerboa/ui/components/common/VoteHelpers.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ fun VoteGeneric(
type: VoteType,
onVoteClick: () -> Unit,
account: Account,
hideScores: Boolean = false,
) {
val iconAndColor = iconAndColor(type, instantScores)

Expand All @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ fun PostVotingTile(
type = VoteType.Upvote,
onVoteClick = onUpvoteClick,
account = account,
hideScores = true,
)

val scoreOrPctStr = instantScores.scoreOrPctStr(voteDisplayMode)
Expand All @@ -306,6 +307,7 @@ fun PostVotingTile(
type = VoteType.Downvote,
onVoteClick = onDownvoteClick,
account = account,
hideScores = true,
)
}
}
Expand Down

0 comments on commit 7e753bd

Please sign in to comment.