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_title">Closed poll</string>
|
||||||
<string name="closed_poll_option_description">Results are only revealed when you end the 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="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">Active polls</string>
|
||||||
<string name="room_polls_active_no_item">There are no active polls in this room</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>
|
<string name="room_polls_ended">Past polls</string>
|
||||||
|
@ -75,7 +75,12 @@ internal class EncryptedEventRelationsAggregationProcessor @Inject constructor(
|
|||||||
RelationType.REFERENCE -> {
|
RelationType.REFERENCE -> {
|
||||||
// can we / should we do we something for UTD reference??
|
// can we / should we do we something for UTD reference??
|
||||||
Timber.w("## UTD reference in room $roomId related to ${encryptedEventContent.relatesTo.eventId}")
|
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 -> {
|
RelationType.ANNOTATION -> {
|
||||||
// can we / should we do we something for UTD annotation??
|
// can we / should we do we something for UTD annotation??
|
||||||
|
@ -31,11 +31,11 @@ class PollItemViewStateFactory @Inject constructor(
|
|||||||
private val stringProvider: StringProvider,
|
private val stringProvider: StringProvider,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
// TODO update unit tests
|
||||||
fun create(
|
fun create(
|
||||||
pollContent: MessagePollContent,
|
pollContent: MessagePollContent,
|
||||||
informationData: MessageInformationData,
|
informationData: MessageInformationData,
|
||||||
): PollViewState {
|
): PollViewState {
|
||||||
// TODO add new field in ViewState to reflect decryption error of related events
|
|
||||||
val pollCreationInfo = pollContent.getBestPollCreationInfo()
|
val pollCreationInfo = pollContent.getBestPollCreationInfo()
|
||||||
|
|
||||||
val question = pollCreationInfo?.question?.getBestQuestion().orEmpty()
|
val question = pollCreationInfo?.question?.getBestQuestion().orEmpty()
|
||||||
@ -84,9 +84,14 @@ class PollItemViewStateFactory @Inject constructor(
|
|||||||
totalVotes: Int,
|
totalVotes: Int,
|
||||||
winnerVoteCount: Int?,
|
winnerVoteCount: Int?,
|
||||||
): PollViewState {
|
): 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(
|
return PollViewState(
|
||||||
question = question,
|
question = question,
|
||||||
votesStatus = stringProvider.getQuantityString(R.plurals.poll_total_vote_count_after_ended, totalVotes, totalVotes),
|
votesStatus = totalVotesText,
|
||||||
canVote = false,
|
canVote = false,
|
||||||
optionViewStates = pollCreationInfo?.answers?.map { answer ->
|
optionViewStates = pollCreationInfo?.answers?.map { answer ->
|
||||||
val voteSummary = pollResponseSummary?.getVoteSummaryOfAnOption(answer.id ?: "")
|
val voteSummary = pollResponseSummary?.getVoteSummaryOfAnOption(answer.id ?: "")
|
||||||
@ -127,9 +132,14 @@ class PollItemViewStateFactory @Inject constructor(
|
|||||||
pollResponseSummary: PollResponseData?,
|
pollResponseSummary: PollResponseData?,
|
||||||
totalVotes: Int
|
totalVotes: Int
|
||||||
): PollViewState {
|
): 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(
|
return PollViewState(
|
||||||
question = question,
|
question = question,
|
||||||
votesStatus = stringProvider.getQuantityString(R.plurals.poll_total_vote_count_before_ended_and_voted, totalVotes, totalVotes),
|
votesStatus = totalVotesText,
|
||||||
canVote = true,
|
canVote = true,
|
||||||
optionViewStates = pollCreationInfo?.answers?.map { answer ->
|
optionViewStates = pollCreationInfo?.answers?.map { answer ->
|
||||||
val isMyVote = pollResponseSummary?.myVote == answer.id
|
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) {
|
val totalVotesText = if (totalVotes == 0) {
|
||||||
stringProvider.getString(R.string.poll_no_votes_cast)
|
stringProvider.getString(R.string.poll_no_votes_cast)
|
||||||
} else {
|
} else {
|
||||||
|
@ -90,7 +90,8 @@ data class PollResponseData(
|
|||||||
val votes: Map<String, PollVoteSummaryData>?,
|
val votes: Map<String, PollVoteSummaryData>?,
|
||||||
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,
|
||||||
) : Parcelable {
|
) : Parcelable {
|
||||||
|
|
||||||
fun getVoteSummaryOfAnOption(optionId: String) = votes?.get(optionId)
|
fun getVoteSummaryOfAnOption(optionId: String) = votes?.get(optionId)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user