diff --git a/Riot/Modules/Room/CellData/RoomBubbleCellData.m b/Riot/Modules/Room/CellData/RoomBubbleCellData.m index e981c0406d..27156fee02 100644 --- a/Riot/Modules/Room/CellData/RoomBubbleCellData.m +++ b/Riot/Modules/Room/CellData/RoomBubbleCellData.m @@ -165,7 +165,7 @@ - (instancetype)initWithEvent:(MXEvent *)event andRoomState:(MXRoomState *)roomS self.collapsable = NO; self.collapsed = NO; - [self updateBeaconInfoSummaryWithEventId:event.eventId]; + [self updateBeaconInfoSummaryWithId:event.eventId andEvent:event]; break; } case MXEventTypeCustom: @@ -224,7 +224,7 @@ - (NSUInteger)updateEvent:(NSString *)eventId withEvent:(MXEvent *)event if (self.tag == RoomBubbleCellDataTagLiveLocation) { - [self updateBeaconInfoSummaryWithEventId:eventId]; + [self updateBeaconInfoSummaryWithId:eventId andEvent:event]; } return retVal; @@ -1361,10 +1361,27 @@ - (void)refreshURLPreviewForEventId:(NSString *)eventId }]; } -- (void)updateBeaconInfoSummaryWithEventId:(NSString *)eventId +- (void)updateBeaconInfoSummaryWithId:(NSString *)eventId andEvent:(MXEvent*)event { + if (event.eventType != MXEventTypeBeaconInfo) + { + MXLogError(@"[RoomBubbleCellData] Try to update beacon info summary with wrong event type with event id %@", eventId); + return; + } + id beaconInfoSummary = [self.mxSession.aggregations.beaconAggregations beaconInfoSummaryFor:eventId inRoomWithId:self.roomId]; + if (!beaconInfoSummary) + { + MXBeaconInfo *beaconInfo = [[MXBeaconInfo alloc] initWithMXEvent:event]; + + // A start beacon info event (isLive == true) should have an associated BeaconInfoSummary + if (beaconInfo && beaconInfo.isLive) + { + MXLogError(@"[RoomBubbleCellData] No beacon info summary found for beacon info start event with id %@", eventId); + } + } + self.beaconInfoSummary = beaconInfoSummary; }