Merge pull request #6138 from vector-im/maximee/PSF-984_lls_fix_timeline_refresh_behavior

6103: Handle refreshing timeline with listner on beaconInfoSummary
This commit is contained in:
MaximeEvrard42 2022-05-11 09:56:56 +02:00 committed by GitHub
commit 9646cbaa48
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 49 additions and 4 deletions

View file

@ -95,7 +95,7 @@ typedef NS_ENUM(NSInteger, RoomBubbleCellDataTag)
*/
@property(nonatomic) BOOL isKeyVerificationOperationPending;
@property(nonatomic, strong, readonly) id<MXBeaconInfoSummaryProtocol> beaconInfoSummary;
@property(nonatomic, strong) id<MXBeaconInfoSummaryProtocol> beaconInfoSummary;
/**
Index of the component which needs a sent tick displayed. -1 if none.

View file

@ -38,8 +38,6 @@ 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

View file

@ -41,6 +41,9 @@ const CGFloat kTypingCellHeight = 24;
// Observe key verification transaction changes
@property (nonatomic, weak) id keyVerificationTransactionDidChangeNotificationObserver;
// Listen to location beacon received
@property (nonatomic, weak) id beaconInfoSummaryListener;
// Timer used to debounce cells refresh
@property (nonatomic, strong) NSTimer *refreshCellsTimer;
@ -100,6 +103,7 @@ const CGFloat kTypingCellHeight = 24;
[self registerKeyVerificationRequestNotification];
[self registerKeyVerificationTransactionNotification];
[self registerTrustLevelDidChangeNotifications];
[self registerBeaconInfoSummaryListner];
self.encryptionTrustLevel = RoomEncryptionTrustLevelUnknown;
}
@ -178,9 +182,14 @@ const CGFloat kTypingCellHeight = 24;
{
[[NSNotificationCenter defaultCenter] removeObserver:self.keyVerificationTransactionDidChangeNotificationObserver];
}
[self.mxSession.threadingService removeDelegate:self];
if (self.beaconInfoSummaryListener)
{
[self.mxSession.aggregations.beaconAggregations removeListener:self.beaconInfoSummaryListener];
}
[super destroy];
}
@ -753,6 +762,43 @@ const CGFloat kTypingCellHeight = 24;
}];
}
- (void)registerBeaconInfoSummaryListner
{
MXWeakify(self);
self.beaconInfoSummaryListener = [self.mxSession.aggregations.beaconAggregations listenToBeaconInfoSummaryUpdateInRoomWithId:self.roomId handler:^(id<MXBeaconInfoSummaryProtocol> beaconInfoSummary) {
MXStrongifyAndReturnIfNil(self);
[self refreshFirstCellWithBeaconInfoSummary:beaconInfoSummary];
}];
}
- (void)refreshFirstCellWithBeaconInfoSummary:(id<MXBeaconInfoSummaryProtocol>)beaconInfoSummary
{
NSUInteger cellIndex;
__block RoomBubbleCellData *roomBubbleCellData;
@synchronized (bubbles)
{
cellIndex = [bubbles indexOfObjectPassingTest:^BOOL(id<MXKRoomBubbleCellDataStoring> _Nonnull cellData, NSUInteger idx, BOOL * _Nonnull stop) {
if ([cellData isKindOfClass:[RoomBubbleCellData class]])
{
roomBubbleCellData = (RoomBubbleCellData*)cellData;
if ([roomBubbleCellData.beaconInfoSummary.id isEqualToString:beaconInfoSummary.id])
{
*stop = YES;
return YES;
}
}
return NO;
}];
}
if (cellIndex != NSNotFound)
{
roomBubbleCellData.beaconInfoSummary = beaconInfoSummary;
[self refreshCells];
}
}
- (BOOL)shouldFetchKeyVerificationForEvent:(MXEvent*)event
{
if (!event)

1
changelog.d/6103.bugfix Normal file
View file

@ -0,0 +1 @@
Location sharing: handle correctly timeline refresh after reception of beacon from live location sharing