RoomBubbleCellData: Handle live location cell and beacon info summary.

This commit is contained in:
SBiOSoftWhare
2022-04-22 11:51:22 +02:00
parent 4f3a7dcd2d
commit 0bf0af8e5a
2 changed files with 42 additions and 1 deletions
@@ -38,6 +38,8 @@ NSString *const URLPreviewDidUpdateNotification = @"URLPreviewDidUpdateNotificat
// Flags to "Show All" reactions for an event
@property(nonatomic) NSMutableSet<NSString* /* eventId */> *eventsToShowAllReactions;
@property(nonatomic, strong, readwrite) id<MXBeaconInfoSummaryProtocol> beaconInfoSummary;
@end
@implementation RoomBubbleCellData
@@ -159,6 +161,15 @@ NSString *const URLPreviewDidUpdateNotification = @"URLPreviewDidUpdateNotificat
break;
}
case MXEventTypeBeaconInfo:
{
self.tag = RoomBubbleCellDataTagLiveLocation;
self.collapsable = NO;
self.collapsed = NO;
[self updateBeaconInfoSummaryWithEventId:event.eventId];
}
break;
case MXEventTypeCustom:
{
if ([event.type isEqualToString:kWidgetMatrixEventTypeString]
@@ -210,6 +221,11 @@ NSString *const URLPreviewDidUpdateNotification = @"URLPreviewDidUpdateNotificat
// Update any URL preview data as necessary.
[self refreshURLPreviewForEventId:event.eventId];
if (self.tag == RoomBubbleCellDataTagLiveLocation)
{
[self updateBeaconInfoSummaryWithEventId:eventId];
}
return retVal;
}
@@ -279,6 +295,17 @@ NSString *const URLPreviewDidUpdateNotification = @"URLPreviewDidUpdateNotificat
return NO;
}
if (self.tag == RoomBubbleCellDataTagLiveLocation)
{
// If the summary does not exist do show the cell
if (!self.beaconInfoSummary)
{
return YES;
}
return NO;
}
return [super hasNoDisplay];
}
@@ -983,6 +1010,9 @@ NSString *const URLPreviewDidUpdateNotification = @"URLPreviewDidUpdateNotificat
case RoomBubbleCellDataTagLocation:
shouldAddEvent = NO;
break;
case RoomBubbleCellDataTagLiveLocation:
shouldAddEvent = NO;
break;
default:
break;
}
@@ -1294,5 +1324,11 @@ NSString *const URLPreviewDidUpdateNotification = @"URLPreviewDidUpdateNotificat
}];
}
- (void)updateBeaconInfoSummaryWithEventId:(NSString *)eventId
{
MXBeaconInfoSummary *beaconInfoSummary = [self.mxSession.aggregations.beaconAggegations beaconInfoSummaryFor:eventId inRoomWithId:self.roomId];
self.beaconInfoSummary = beaconInfoSummary;
}
@end