diff --git a/Riot/Modules/Room/CellData/RoomBubbleCellData.m b/Riot/Modules/Room/CellData/RoomBubbleCellData.m index 5a9890b31..7339db8e8 100644 --- a/Riot/Modules/Room/CellData/RoomBubbleCellData.m +++ b/Riot/Modules/Room/CellData/RoomBubbleCellData.m @@ -1098,6 +1098,11 @@ NSString *const URLPreviewDidUpdateNotification = @"URLPreviewDidUpdateNotificat // Set the preview data. MXWeakify(self); + NSDictionary *userInfo = @{ + @"eventId": lastComponent.event.eventId, + @"roomId": self.roomId + }; + [URLPreviewManager.shared previewFor:lastComponent.link and:lastComponent.event with:self.mxSession @@ -1108,7 +1113,7 @@ NSString *const URLPreviewDidUpdateNotification = @"URLPreviewDidUpdateNotificat self.urlPreviewData = urlPreviewData; dispatch_async(dispatch_get_main_queue(), ^{ - [NSNotificationCenter.defaultCenter postNotificationName:URLPreviewDidUpdateNotification object:self]; + [NSNotificationCenter.defaultCenter postNotificationName:URLPreviewDidUpdateNotification object:nil userInfo:userInfo]; }); } failure:^(NSError * _Nullable error) { @@ -1118,7 +1123,7 @@ NSString *const URLPreviewDidUpdateNotification = @"URLPreviewDidUpdateNotificat self.showURLPreview = NO; dispatch_async(dispatch_get_main_queue(), ^{ - [NSNotificationCenter.defaultCenter postNotificationName:URLPreviewDidUpdateNotification object:self]; + [NSNotificationCenter.defaultCenter postNotificationName:URLPreviewDidUpdateNotification object:nil userInfo:userInfo]; }); }]; } diff --git a/Riot/Modules/Room/DataSources/RoomDataSource.m b/Riot/Modules/Room/DataSources/RoomDataSource.m index 4b2366440..b12153673 100644 --- a/Riot/Modules/Room/DataSources/RoomDataSource.m +++ b/Riot/Modules/Room/DataSources/RoomDataSource.m @@ -97,10 +97,17 @@ const CGFloat kTypingCellHeight = 24; }]; // Observe URL preview updates. - kURLPreviewDidUpdateNotificationObserver = [NSNotificationCenter.defaultCenter addObserverForName:URLPreviewDidUpdateNotification object:nil queue:NSOperationQueue.mainQueue usingBlock:^(NSNotification * _Nonnull note) { + kURLPreviewDidUpdateNotificationObserver = [NSNotificationCenter.defaultCenter addObserverForName:URLPreviewDidUpdateNotification object:nil queue:NSOperationQueue.mainQueue usingBlock:^(NSNotification * _Nonnull notification) { - // Refresh all cells. - [self refreshCells]; + if (![(NSString*)notification.userInfo[@"roomId"] isEqualToString:self.roomId] || !self.delegate) + { + return; + } + + // Refresh the updated cell. + // Note - it doesn't appear as though MXKRoomViewController actually uses the index path. + NSInteger index = [self indexOfCellDataWithEventId:(NSString*)notification.userInfo[@"eventId"]]; + [self.delegate dataSource:self didCellChange:[NSIndexPath indexPathWithIndex:index]]; }]; [self registerKeyVerificationRequestNotification];