Skip to content

Commit

Permalink
Try to fix comments finally!
Browse files Browse the repository at this point in the history
  • Loading branch information
mopsalarm committed Jun 18, 2018
1 parent b2fbe8e commit 9d25b41
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
3 changes: 3 additions & 0 deletions app/src/main/java/com/pr0gramm/app/services/VoteService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@ class VoteService(private val api: Api,
for (cachedVote in cachedVotes)
result.put(cachedVote.itemId, cachedVote.vote)

// add "NEUTRAL" votes for every unknown item
ids.forEach { result.putIfAbsent(it, Vote.NEUTRAL) }

result
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -584,9 +584,9 @@ class PostFragment : BaseFragment("PostFragment"), NewTagDialogFragment.OnAddNew
commentVoteSubscription?.unsubscribe()

commentVoteSubscription = comments
.switchMap {
.switchMap { comments ->
voteService
.getCommentVotes(it)
.getCommentVotes(comments)
.subscribeOnBackground()
.onErrorResumeEmpty()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,13 @@ class CommentsAdapter(

fun updateVotes(votes: TLongObjectMap<Vote>) {
val currentVotes = TLongObjectHashMap(votes)
val baseVotes = state.baseVotes ?: TLongObjectHashMap(votes)

// add new votes as base votes
val baseVotes = TLongObjectHashMap(state.baseVotes ?: votes)
votes.forEachEntry { id, vote ->
baseVotes.putIfAbsent(id, vote)
true
}

state = state.copy(baseVotes = baseVotes, currentVotes = currentVotes)
}
Expand Down

0 comments on commit 9d25b41

Please sign in to comment.