Renaming field in PollResponseData for better clarity
This commit is contained in:
parent
94dd599f13
commit
d1ce15bf18
|
@ -83,7 +83,7 @@ class PollItemViewStateFactory @Inject constructor(
|
||||||
totalVotes: Int,
|
totalVotes: Int,
|
||||||
winnerVoteCount: Int?,
|
winnerVoteCount: Int?,
|
||||||
): PollViewState {
|
): PollViewState {
|
||||||
val totalVotesText = if (pollResponseSummary?.hasDecryptionError.orFalse()) {
|
val totalVotesText = if (pollResponseSummary?.hasEncryptedRelatedEvents.orFalse()) {
|
||||||
stringProvider.getString(R.string.unable_to_decrypt_some_events_in_poll)
|
stringProvider.getString(R.string.unable_to_decrypt_some_events_in_poll)
|
||||||
} else {
|
} else {
|
||||||
stringProvider.getQuantityString(R.plurals.poll_total_vote_count_after_ended, totalVotes, totalVotes)
|
stringProvider.getQuantityString(R.plurals.poll_total_vote_count_after_ended, totalVotes, totalVotes)
|
||||||
|
@ -131,7 +131,7 @@ class PollItemViewStateFactory @Inject constructor(
|
||||||
pollResponseSummary: PollResponseData?,
|
pollResponseSummary: PollResponseData?,
|
||||||
totalVotes: Int
|
totalVotes: Int
|
||||||
): PollViewState {
|
): PollViewState {
|
||||||
val totalVotesText = if (pollResponseSummary?.hasDecryptionError.orFalse()) {
|
val totalVotesText = if (pollResponseSummary?.hasEncryptedRelatedEvents.orFalse()) {
|
||||||
stringProvider.getString(R.string.unable_to_decrypt_some_events_in_poll)
|
stringProvider.getString(R.string.unable_to_decrypt_some_events_in_poll)
|
||||||
} else {
|
} else {
|
||||||
stringProvider.getQuantityString(R.plurals.poll_total_vote_count_before_ended_and_voted, totalVotes, totalVotes)
|
stringProvider.getQuantityString(R.plurals.poll_total_vote_count_before_ended_and_voted, totalVotes, totalVotes)
|
||||||
|
|
|
@ -45,7 +45,7 @@ class PollResponseDataFactory @Inject constructor(
|
||||||
},
|
},
|
||||||
winnerVoteCount = it.aggregatedContent?.winnerVoteCount ?: 0,
|
winnerVoteCount = it.aggregatedContent?.winnerVoteCount ?: 0,
|
||||||
totalVotes = it.aggregatedContent?.totalVotes ?: 0,
|
totalVotes = it.aggregatedContent?.totalVotes ?: 0,
|
||||||
hasDecryptionError = it.encryptedRelatedEventIds.isNotEmpty(),
|
hasEncryptedRelatedEvents = it.encryptedRelatedEventIds.isNotEmpty(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,7 @@ data class PollResponseData(
|
||||||
val totalVotes: Int = 0,
|
val totalVotes: Int = 0,
|
||||||
val winnerVoteCount: Int = 0,
|
val winnerVoteCount: Int = 0,
|
||||||
val isClosed: Boolean = false,
|
val isClosed: Boolean = false,
|
||||||
val hasDecryptionError: Boolean = false,
|
val hasEncryptedRelatedEvents: Boolean = false,
|
||||||
) : Parcelable {
|
) : Parcelable {
|
||||||
|
|
||||||
fun getVoteSummaryOfAnOption(optionId: String) = votes?.get(optionId)
|
fun getVoteSummaryOfAnOption(optionId: String) = votes?.get(optionId)
|
||||||
|
|
|
@ -136,7 +136,7 @@ class PollItemViewStateFactoryTest {
|
||||||
// Given
|
// Given
|
||||||
val stringProvider = FakeStringProvider()
|
val stringProvider = FakeStringProvider()
|
||||||
val pollItemViewStateFactory = PollItemViewStateFactory(stringProvider.instance)
|
val pollItemViewStateFactory = PollItemViewStateFactory(stringProvider.instance)
|
||||||
val closedPollSummary = A_POLL_RESPONSE_DATA.copy(isClosed = true, hasDecryptionError = true)
|
val closedPollSummary = A_POLL_RESPONSE_DATA.copy(isClosed = true, hasEncryptedRelatedEvents = true)
|
||||||
val closedPollInformationData = A_MESSAGE_INFORMATION_DATA.copy(pollResponseAggregatedSummary = closedPollSummary)
|
val closedPollInformationData = A_MESSAGE_INFORMATION_DATA.copy(pollResponseAggregatedSummary = closedPollSummary)
|
||||||
|
|
||||||
// When
|
// When
|
||||||
|
@ -220,7 +220,7 @@ class PollItemViewStateFactoryTest {
|
||||||
totalVotes = 1,
|
totalVotes = 1,
|
||||||
myVote = A_POLL_OPTION_IDS[0],
|
myVote = A_POLL_OPTION_IDS[0],
|
||||||
votes = mapOf(A_POLL_OPTION_IDS[0] to PollVoteSummaryData(total = 1, percentage = 1.0)),
|
votes = mapOf(A_POLL_OPTION_IDS[0] to PollVoteSummaryData(total = 1, percentage = 1.0)),
|
||||||
hasDecryptionError = true,
|
hasEncryptedRelatedEvents = true,
|
||||||
)
|
)
|
||||||
val disclosedPollContent = A_POLL_CONTENT.copy(
|
val disclosedPollContent = A_POLL_CONTENT.copy(
|
||||||
unstablePollCreationInfo = A_POLL_CONTENT.getBestPollCreationInfo()?.copy(
|
unstablePollCreationInfo = A_POLL_CONTENT.getBestPollCreationInfo()?.copy(
|
||||||
|
|
Loading…
Reference in New Issue