Skip to content

Commit 740d50f

Browse files
authored
Room context preview dismissed unexpectedly (#5993)
- fixed
1 parent 1e99e19 commit 740d50f

File tree

5 files changed

+67
-0
lines changed

5 files changed

+67
-0
lines changed

Riot/Modules/Common/Recents/RecentsViewController.m

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,14 @@ - (void)viewDidLayoutSubviews
366366

367367
- (void)refreshRecentsTable
368368
{
369+
if (!self.recentsUpdateEnabled)
370+
{
371+
isRefreshNeeded = NO;
372+
return;
373+
}
374+
375+
isRefreshNeeded = NO;
376+
369377
// Refresh the tabBar icon badges
370378
[[AppDelegate theDelegate].masterTabBarController refreshTabBarBadges];
371379

@@ -1034,6 +1042,12 @@ - (void)dataSource:(MXKDataSource *)dataSource didRecognizeAction:(NSString *)ac
10341042

10351043
- (void)dataSource:(MXKDataSource *)dataSource didCellChange:(id)changes
10361044
{
1045+
if (!self.recentsUpdateEnabled)
1046+
{
1047+
[super dataSource:dataSource didCellChange:changes];
1048+
return;
1049+
}
1050+
10371051
BOOL cellReloaded = NO;
10381052
if ([changes isKindOfClass:RecentsSectionUpdate.class])
10391053
{
@@ -2502,6 +2516,7 @@ - (UIContextMenuConfiguration *)tableView:(UITableView *)tableView contextMenuCo
25022516
return nil;
25032517
}
25042518

2519+
self.recentsUpdateEnabled = NO;
25052520
return [self.contextMenuProvider contextMenuConfigurationWith:cellData from:cell session:self.dataSource.mxSession];
25062521
}
25072522

@@ -2511,14 +2526,22 @@ - (void)tableView:(UITableView *)tableView willPerformPreviewActionForMenuWithCo
25112526

25122527
if (!roomId)
25132528
{
2529+
self.recentsUpdateEnabled = YES;
25142530
return;
25152531
}
25162532

25172533
[animator addCompletion:^{
2534+
self.recentsUpdateEnabled = YES;
25182535
[self showRoomWithRoomId:roomId inMatrixSession:self.mainSession];
25192536
}];
25202537
}
25212538

2539+
- (UITargetedPreview *)tableView:(UITableView *)tableView previewForDismissingContextMenuWithConfiguration:(UIContextMenuConfiguration *)configuration API_AVAILABLE(ios(13.0))
2540+
{
2541+
self.recentsUpdateEnabled = YES;
2542+
return nil;
2543+
}
2544+
25222545
#pragma mark - RoomContextActionServiceDelegate
25232546

25242547
- (void)roomContextActionServiceDidJoinRoom:(id<RoomContextActionServiceProtocol>)service

Riot/Modules/Home/HomeViewController.m

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -902,6 +902,7 @@ - (UIContextMenuConfiguration *)collectionView:(UICollectionView *)collectionVie
902902
return nil;
903903
}
904904

905+
self.recentsUpdateEnabled = NO;
905906
return [self.contextMenuProvider contextMenuConfigurationWith:cellData from:cell session:self.dataSource.mxSession];
906907
}
907908

@@ -911,12 +912,20 @@ - (void)collectionView:(UICollectionView *)collectionView willPerformPreviewActi
911912

912913
if (!roomId)
913914
{
915+
self.recentsUpdateEnabled = YES;
914916
return;
915917
}
916918

917919
[animator addCompletion:^{
920+
self.recentsUpdateEnabled = YES;
918921
[self showRoomWithRoomId:roomId inMatrixSession:self.mainSession];
919922
}];
920923
}
921924

925+
- (UITargetedPreview *)collectionView:(UICollectionView *)collectionView previewForDismissingContextMenuWithConfiguration:(UIContextMenuConfiguration *)configuration API_AVAILABLE(ios(13.0))
926+
{
927+
self.recentsUpdateEnabled = YES;
928+
return nil;
929+
}
930+
922931
@end

Riot/Modules/MatrixKit/Controllers/MXKRecentListViewController.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ limitations under the License.
5959
The fake top view displayed in case of vertical bounce.
6060
*/
6161
__weak UIView *topview;
62+
63+
/**
64+
`isRefreshNeeded` is set to `YES` if an update of the datasource has been triggered but the UI has not been updated.
65+
It's set to `NO` after a refresh of the UI.
66+
*/
67+
BOOL isRefreshNeeded;
6268
}
6369

6470
@property (weak, nonatomic) IBOutlet UISearchBar *recentsSearchBar;
@@ -83,6 +89,11 @@ limitations under the License.
8389
*/
8490
@property (nonatomic) BOOL enableBarButtonSearch;
8591

92+
/**
93+
Enabled or disabled the UI update after recents syncs. Default YES.
94+
*/
95+
@property (nonatomic, getter=isRecentsUpdateEnabled) BOOL recentsUpdateEnabled;
96+
8697
#pragma mark - Class methods
8798

8899
/**

Riot/Modules/MatrixKit/Controllers/MXKRecentListViewController.m

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ - (void)finalizeInit
8383
{
8484
[super finalizeInit];
8585

86+
_recentsUpdateEnabled = YES;
8687
_enableBarButtonSearch = YES;
8788
}
8889

@@ -169,6 +170,8 @@ - (void)viewWillAppear:(BOOL)animated
169170

170171
// Observe the server sync
171172
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onSyncNotification) name:kMXSessionDidSyncNotification object:nil];
173+
174+
self.recentsUpdateEnabled = YES;
172175
}
173176

174177
- (void)viewWillDisappear:(BOOL)animated
@@ -319,6 +322,10 @@ - (void)displayList:(MXKRecentsDataSource *)listDataSource
319322

320323
- (void)refreshRecentsTable
321324
{
325+
if (!self.recentsUpdateEnabled) return;
326+
327+
isRefreshNeeded = NO;
328+
322329
// For now, do a simple full reload
323330
[self.recentsTableView reloadData];
324331
}
@@ -330,6 +337,16 @@ - (void)hideSearchBar:(BOOL)hidden
330337
[self.view setNeedsUpdateConstraints];
331338
}
332339

340+
- (void)setRecentsUpdateEnabled:(BOOL)activeUpdate
341+
{
342+
_recentsUpdateEnabled = activeUpdate;
343+
344+
if (_recentsUpdateEnabled && isRefreshNeeded)
345+
{
346+
[self refreshRecentsTable];
347+
}
348+
}
349+
333350
#pragma mark - Action
334351

335352
- (IBAction)search:(id)sender
@@ -385,6 +402,12 @@ - (NSString *)cellReuseIdentifierForCellData:(MXKCellData*)cellData
385402

386403
- (void)dataSource:(MXKDataSource *)dataSource didCellChange:(id)changes
387404
{
405+
if (!_recentsUpdateEnabled)
406+
{
407+
isRefreshNeeded = YES;
408+
return;
409+
}
410+
388411
// For now, do a simple full reload
389412
[self refreshRecentsTable];
390413
}

changelog.d/5992.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
RecentsViewController: Room context preview dismissed unexpectedly

0 commit comments

Comments
 (0)