diff --git a/MatrixSDK/MXSession.h b/MatrixSDK/MXSession.h index 352b907bfb..df449e087f 100644 --- a/MatrixSDK/MXSession.h +++ b/MatrixSDK/MXSession.h @@ -339,7 +339,6 @@ FOUNDATION_EXPORT NSString *const kMXSessionNotificationErrorKey; */ FOUNDATION_EXPORT NSString *const kMXSessionNotificationUserIdsArrayKey; - #pragma mark - Other constants /** Fake tag used to identify rooms that do not have tags in `roomsWithTag` and `roomsByTags` methods. diff --git a/MatrixSDK/MXSession.m b/MatrixSDK/MXSession.m index 0d516684e1..222ce9ef84 100644 --- a/MatrixSDK/MXSession.m +++ b/MatrixSDK/MXSession.m @@ -4999,7 +4999,7 @@ - (void)decryptEvents:(NSArray *)events [failedEvents addObject:event]; } } - + onComplete(failedEvents); }]; } diff --git a/MatrixSDK/Room/Polls/PollAggregator.swift b/MatrixSDK/Room/Polls/PollAggregator.swift index e896631d55..7c5b6c054d 100644 --- a/MatrixSDK/Room/Polls/PollAggregator.swift +++ b/MatrixSDK/Room/Polls/PollAggregator.swift @@ -77,8 +77,12 @@ public class PollAggregator { self.pollStartEventId = pollStartEventId self.pollBuilder = PollBuilder() - NotificationCenter.default.addObserver(self, selector: #selector(handleRoomDataFlush), name: NSNotification.Name.mxRoomDidFlushData, object: self.room) - + NotificationCenter.default.addObserver(self, selector: #selector(handleRoomDataFlush), name: .mxRoomDidFlushData, object: self.room) + setupEditListener() + try buildPollStartContent() + } + + private func setupEditListener() { editEventsListener = session.aggregations.listenToEditsUpdate(inRoom: self.room.roomId) { [weak self] event in guard let self = self, self.pollStartEventId == event.relatesTo.eventId @@ -92,8 +96,6 @@ public class PollAggregator { self.delegate?.pollAggregator(self, didFailWithError: PollAggregatorError.invalidPollStartEvent) } } - - try buildPollStartContent() } private func buildPollStartContent() throws { diff --git a/MatrixSDK/Room/Polls/PollBuilder.swift b/MatrixSDK/Room/Polls/PollBuilder.swift index 97c77501a2..44d17127f1 100644 --- a/MatrixSDK/Room/Polls/PollBuilder.swift +++ b/MatrixSDK/Room/Polls/PollBuilder.swift @@ -26,6 +26,7 @@ struct PollBuilder { let poll = Poll() poll.hasBeenEdited = hasBeenEdited + poll.hasDecryptionError = events.contains(where: { $0.isEncrypted && $0.clear == nil }) poll.text = pollStartEventContent.question poll.maxAllowedSelections = max(1, pollStartEventContent.maxSelections.uintValue) diff --git a/MatrixSDK/Room/Polls/PollModels.swift b/MatrixSDK/Room/Polls/PollModels.swift index 4d426b45cb..f8f565cca7 100644 --- a/MatrixSDK/Room/Polls/PollModels.swift +++ b/MatrixSDK/Room/Polls/PollModels.swift @@ -37,6 +37,7 @@ public protocol PollProtocol { var isClosed: Bool { get } var totalAnswerCount: UInt { get } var hasBeenEdited: Bool { get } + var hasDecryptionError: Bool { get } } class PollAnswerOption: PollAnswerOptionProtocol { @@ -56,6 +57,7 @@ class Poll: PollProtocol { var maxAllowedSelections: UInt = 1 var isClosed: Bool = false var hasBeenEdited: Bool = false + var hasDecryptionError: Bool = false var totalAnswerCount: UInt { return self.answerOptions.reduce(0) { $0 + $1.count} diff --git a/changelog.d/pr-1673.change b/changelog.d/pr-1673.change new file mode 100644 index 0000000000..490e464b75 --- /dev/null +++ b/changelog.d/pr-1673.change @@ -0,0 +1 @@ +Polls: handle decryption errors.