Render specific message on decryption error
This commit is contained in:
parent
9ee6888d4b
commit
a42dcbecd7
@ -3190,6 +3190,7 @@
|
|||||||
<string name="open_poll_option_description">Voters see results as soon as they have voted</string>
|
<string name="open_poll_option_description">Voters see results as soon as they have voted</string>
|
||||||
<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="unable_to_decrypt_some_events_in_poll">Due to decryption errors, some votes may not be counted</string>
|
||||||
|
|
||||||
<!-- Location -->
|
<!-- Location -->
|
||||||
<string name="location_activity_title_static_sharing">Share location</string>
|
<string name="location_activity_title_static_sharing">Share location</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 {
|
||||||
|
@ -99,6 +99,7 @@ class MessageInformationDataFactory @Inject constructor(
|
|||||||
memberName = event.senderInfo.disambiguatedDisplayName,
|
memberName = event.senderInfo.disambiguatedDisplayName,
|
||||||
messageLayout = messageLayout,
|
messageLayout = messageLayout,
|
||||||
reactionsSummary = reactionsSummaryFactory.create(event),
|
reactionsSummary = reactionsSummaryFactory.create(event),
|
||||||
|
// TODO extract into a dedicated factory
|
||||||
pollResponseAggregatedSummary = event.annotations?.pollResponseSummary?.let {
|
pollResponseAggregatedSummary = event.annotations?.pollResponseSummary?.let {
|
||||||
PollResponseData(
|
PollResponseData(
|
||||||
myVote = it.aggregatedContent?.myVote,
|
myVote = it.aggregatedContent?.myVote,
|
||||||
@ -110,7 +111,8 @@ class MessageInformationDataFactory @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(),
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
hasBeenEdited = event.hasBeenEdited(),
|
hasBeenEdited = event.hasBeenEdited(),
|
||||||
|
@ -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