Render specific message on decryption error
This commit is contained in:
parent
c0c5e208bd
commit
3b9faa5f31
@ -3194,6 +3194,7 @@
|
||||
<string name="closed_poll_option_title">Closed poll</string>
|
||||
<string name="closed_poll_option_description">Results are only revealed when you end the poll</string>
|
||||
<string name="ended_poll_indicator">Ended the poll.</string>
|
||||
<string name="unable_to_decrypt_some_events_in_poll">Due to decryption errors, some votes may not be counted</string>
|
||||
<string name="room_polls_active">Active polls</string>
|
||||
<string name="room_polls_active_no_item">There are no active polls in this room</string>
|
||||
<string name="room_polls_ended">Past polls</string>
|
||||
|
@ -75,7 +75,12 @@ internal class EncryptedEventRelationsAggregationProcessor @Inject constructor(
|
||||
RelationType.REFERENCE -> {
|
||||
// can we / should we do we something for UTD reference??
|
||||
Timber.w("## UTD reference in room $roomId related to ${encryptedEventContent.relatesTo.eventId}")
|
||||
encryptedReferenceAggregationProcessor.handle(realm, event, isLocalEcho, encryptedEventContent.relatesTo.eventId)
|
||||
encryptedReferenceAggregationProcessor.handle(
|
||||
realm = realm,
|
||||
event = event,
|
||||
isLocalEcho = isLocalEcho,
|
||||
relatedEventId = encryptedEventContent.relatesTo.eventId
|
||||
)
|
||||
}
|
||||
RelationType.ANNOTATION -> {
|
||||
// can we / should we do we something for UTD annotation??
|
||||
|
@ -31,11 +31,11 @@ class PollItemViewStateFactory @Inject constructor(
|
||||
private val stringProvider: StringProvider,
|
||||
) {
|
||||
|
||||
// TODO update unit tests
|
||||
fun create(
|
||||
pollContent: MessagePollContent,
|
||||
informationData: MessageInformationData,
|
||||
): PollViewState {
|
||||
// TODO add new field in ViewState to reflect decryption error of related events
|
||||
val pollCreationInfo = pollContent.getBestPollCreationInfo()
|
||||
|
||||
val question = pollCreationInfo?.question?.getBestQuestion().orEmpty()
|
||||
@ -84,9 +84,14 @@ class PollItemViewStateFactory @Inject constructor(
|
||||
totalVotes: Int,
|
||||
winnerVoteCount: Int?,
|
||||
): PollViewState {
|
||||
val totalVotesText = if (pollResponseSummary?.hasDecryptionError.orFalse()) {
|
||||
stringProvider.getString(R.string.unable_to_decrypt_some_events_in_poll)
|
||||
} else {
|
||||
stringProvider.getQuantityString(R.plurals.poll_total_vote_count_after_ended, totalVotes, totalVotes)
|
||||
}
|
||||
return PollViewState(
|
||||
question = question,
|
||||
votesStatus = stringProvider.getQuantityString(R.plurals.poll_total_vote_count_after_ended, totalVotes, totalVotes),
|
||||
votesStatus = totalVotesText,
|
||||
canVote = false,
|
||||
optionViewStates = pollCreationInfo?.answers?.map { answer ->
|
||||
val voteSummary = pollResponseSummary?.getVoteSummaryOfAnOption(answer.id ?: "")
|
||||
@ -127,9 +132,14 @@ class PollItemViewStateFactory @Inject constructor(
|
||||
pollResponseSummary: PollResponseData?,
|
||||
totalVotes: Int
|
||||
): PollViewState {
|
||||
val totalVotesText = if (pollResponseSummary?.hasDecryptionError.orFalse()) {
|
||||
stringProvider.getString(R.string.unable_to_decrypt_some_events_in_poll)
|
||||
} else {
|
||||
stringProvider.getQuantityString(R.plurals.poll_total_vote_count_before_ended_and_voted, totalVotes, totalVotes)
|
||||
}
|
||||
return PollViewState(
|
||||
question = question,
|
||||
votesStatus = stringProvider.getQuantityString(R.plurals.poll_total_vote_count_before_ended_and_voted, totalVotes, totalVotes),
|
||||
votesStatus = totalVotesText,
|
||||
canVote = true,
|
||||
optionViewStates = pollCreationInfo?.answers?.map { answer ->
|
||||
val isMyVote = pollResponseSummary?.myVote == answer.id
|
||||
@ -145,7 +155,11 @@ class PollItemViewStateFactory @Inject constructor(
|
||||
)
|
||||
}
|
||||
|
||||
private fun createReadyPollViewState(question: String, pollCreationInfo: PollCreationInfo?, totalVotes: Int): PollViewState {
|
||||
private fun createReadyPollViewState(
|
||||
question: String,
|
||||
pollCreationInfo: PollCreationInfo?,
|
||||
totalVotes: Int
|
||||
): PollViewState {
|
||||
val totalVotesText = if (totalVotes == 0) {
|
||||
stringProvider.getString(R.string.poll_no_votes_cast)
|
||||
} else {
|
||||
|
@ -90,7 +90,8 @@ data class PollResponseData(
|
||||
val votes: Map<String, PollVoteSummaryData>?,
|
||||
val totalVotes: Int = 0,
|
||||
val winnerVoteCount: Int = 0,
|
||||
val isClosed: Boolean = false
|
||||
val isClosed: Boolean = false,
|
||||
val hasDecryptionError: Boolean = false,
|
||||
) : Parcelable {
|
||||
|
||||
fun getVoteSummaryOfAnOption(optionId: String) = votes?.get(optionId)
|
||||
|
Loading…
x
Reference in New Issue
Block a user