Skip to content

Commit

Permalink
Merge pull request #941 from StepicOrg/hotfix/1.207.1
Browse files Browse the repository at this point in the history
Hotfix/1.207.1
  • Loading branch information
rostikjoystick authored Jan 28, 2022
2 parents 3915fa5 + 0fbd050 commit 81f6f5b
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ constructor(
val vote = commentsData
.votes
.find { it.id == comment.vote }
?: return@mapNotNull null

val solution = comment
.submission
Expand Down Expand Up @@ -57,7 +56,7 @@ constructor(
comment = comment,
textData = result,
user = user,
voteStatus = CommentItem.Data.VoteStatus.Resolved(vote),
voteStatus = if (vote == null) CommentItem.Data.VoteStatus.Unavailable else CommentItem.Data.VoteStatus.Resolved(vote),
isFocused = discussionId == comment.id,
solution = solution
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ sealed class CommentItem {
sealed class VoteStatus {
data class Resolved(val vote: Vote) : VoteStatus()
object Pending : VoteStatus()
object Unavailable : VoteStatus()
}

data class Solution(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class CommentDataAdapterDelegate(

voteStatusViewStateDelegate.addState<CommentItem.Data.VoteStatus.Resolved>(commentLike, commentDislike)
voteStatusViewStateDelegate.addState<CommentItem.Data.VoteStatus.Pending>(root.commentVoteProgress)
voteStatusViewStateDelegate.addState<CommentItem.Data.VoteStatus.Unavailable>(commentLike, commentDislike)

commentTagsAdapter += CommentTagsAdapterDelegate()
with(commentTags) {
Expand Down Expand Up @@ -123,25 +124,32 @@ class CommentDataAdapterDelegate(
commentLike.text = data.comment.epicCount.toString()
commentDislike.text = data.comment.abuseCount.toString()

commentLike.isEnabled = data.comment.actions?.vote == true
commentDislike.isEnabled = data.comment.actions?.vote == true

if (data.voteStatus is CommentItem.Data.VoteStatus.Resolved) {
commentLike.alpha =
when (data.voteStatus.vote.value) {
Vote.Value.LIKE ->
1f
else ->
0.5f
}
commentLike.isEnabled = data.comment.actions?.vote == true && data.voteStatus is CommentItem.Data.VoteStatus.Resolved
commentDislike.isEnabled = data.comment.actions?.vote == true && data.voteStatus is CommentItem.Data.VoteStatus.Resolved

when (data.voteStatus) {
is CommentItem.Data.VoteStatus.Resolved -> {
commentLike.alpha =
when (data.voteStatus.vote.value) {
Vote.Value.LIKE ->
1f
else ->
0.5f
}

commentDislike.alpha =
when (data.voteStatus.vote.value) {
Vote.Value.DISLIKE ->
1f
else ->
0.5f
}
commentDislike.alpha =
when (data.voteStatus.vote.value) {
Vote.Value.DISLIKE ->
1f
else ->
0.5f
}
}
is CommentItem.Data.VoteStatus.Unavailable -> {
commentLike.alpha = 0.5f
commentDislike.alpha = 0.5f
}
else -> {}
}

// solution
Expand Down
4 changes: 2 additions & 2 deletions dependencies.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ext.versions = [
code : 2237,
name : '1.207',
code : 2238,
name : '1.207.1',

minSdk : 21,
targetSdk : 30,
Expand Down

0 comments on commit 81f6f5b

Please sign in to comment.