RoomDataSource: Handle live location sharing deletion.

This commit is contained in:
SBiOSoftWhare
2022-07-25 15:02:33 +02:00
parent b9b563928d
commit 7f0fee41f3
+20 -1
View File
@@ -44,6 +44,9 @@ const CGFloat kTypingCellHeight = 24;
// Listen to location beacon received
@property (nonatomic, weak) id beaconInfoSummaryListener;
// Listen to location beacon info deletion
@property (nonatomic, weak) id beaconInfoSummaryDeletionListener;
// Timer used to debounce cells refresh
@property (nonatomic, strong) NSTimer *refreshCellsTimer;
@@ -190,6 +193,11 @@ const CGFloat kTypingCellHeight = 24;
[self.mxSession.aggregations.beaconAggregations removeListener:self.beaconInfoSummaryListener];
}
if (self.beaconInfoSummaryDeletionListener)
{
[self.mxSession.aggregations.beaconAggregations removeListener:self.beaconInfoSummaryDeletionListener];
}
[super destroy];
}
@@ -770,9 +778,20 @@ const CGFloat kTypingCellHeight = 24;
[self updateCurrentUserLocationSharingStatus];
[self refreshFirstCellWithBeaconInfoSummary:beaconInfoSummary];
}];
self.beaconInfoSummaryDeletionListener = [self.mxSession.aggregations.beaconAggregations listenToBeaconInfoSummaryDeletionInRoomWithId:self.roomId handler:^(NSString * _Nonnull beaconInfoEventId) {
MXStrongifyAndReturnIfNil(self);
[self updateCurrentUserLocationSharingStatus];
[self refreshFirstCellWithBeaconInfoSummaryIdentifier:beaconInfoEventId updatedBeaconInfoSummary:nil];
}];
}
- (void)refreshFirstCellWithBeaconInfoSummary:(id<MXBeaconInfoSummaryProtocol>)beaconInfoSummary
{
[self refreshFirstCellWithBeaconInfoSummaryIdentifier:beaconInfoSummary.id updatedBeaconInfoSummary:beaconInfoSummary];
}
- (void)refreshFirstCellWithBeaconInfoSummaryIdentifier:(NSString*)beaconInfoEventId updatedBeaconInfoSummary:(nullable id<MXBeaconInfoSummaryProtocol>)beaconInfoSummary
{
NSUInteger cellIndex;
__block RoomBubbleCellData *roomBubbleCellData;
@@ -783,7 +802,7 @@ const CGFloat kTypingCellHeight = 24;
if ([cellData isKindOfClass:[RoomBubbleCellData class]])
{
roomBubbleCellData = (RoomBubbleCellData*)cellData;
if ([roomBubbleCellData.beaconInfoSummary.id isEqualToString:beaconInfoSummary.id])
if ([roomBubbleCellData.beaconInfoSummary.id isEqualToString:beaconInfoEventId])
{
*stop = YES;
return YES;