Skip to content

Commit

Permalink
element-hq/element-ios/issues/5114 - Prevent unnecessary poll respons…
Browse files Browse the repository at this point in the history
…e updates coming from read receipts and only listen to events relating to the original poll in the poll aggregator event listener.
  • Loading branch information
stefanceriu committed Nov 24, 2021
1 parent 5c41239 commit 6126b67
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion MatrixSDK/Data/MXEventTimeline.m
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,10 @@ - (void)addEvent:(MXEvent*)event direction:(MXTimelineDirection)direction fromSt
}

// Consider that a message sent by a user has been read by him
[room storeLocalReceipt:kMXEventTypeStringRead eventId:event.eventId userId:event.sender ts:event.originServerTs];
// Ignore poll responses and avoid unnecessary updates
if (![event.type isEqualToString:kMXEventTypeStringPollResponse]) {
[room storeLocalReceipt:kMXEventTypeStringRead eventId:event.eventId userId:event.sender ts:event.originServerTs];
}
}

// Store the event
Expand Down
5 changes: 4 additions & 1 deletion MatrixSDK/Room/Polls/PollAggregator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@ public class PollAggregator {
self.events.append(contentsOf: response.chunk)

self.eventListener = self.room.listen(toEventsOfTypes: [kMXEventTypeStringPollResponse, kMXEventTypeStringPollEnd]) { [weak self] event, direction, state in
guard let self = self, let event = event else {
guard let self = self,
let event = event,
let relatedEventId = event.relatesTo?.eventId,
relatedEventId == self.pollStartEvent.eventId else {
return
}

Expand Down

0 comments on commit 6126b67

Please sign in to comment.