Merge branch 'develop' into andy/5619_home_reloads

This commit is contained in:
Andy Uhnak
2022-04-07 10:49:15 +01:00
182 changed files with 7162 additions and 901 deletions
@@ -36,7 +36,7 @@
NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewControllerDataReadyNotification";
@interface RecentsViewController () <CreateRoomCoordinatorBridgePresenterDelegate, RoomsDirectoryCoordinatorBridgePresenterDelegate, RoomNotificationSettingsCoordinatorBridgePresenterDelegate, DialpadViewControllerDelegate, ExploreRoomCoordinatorBridgePresenterDelegate, SpaceChildRoomDetailBridgePresenterDelegate>
@interface RecentsViewController () <CreateRoomCoordinatorBridgePresenterDelegate, RoomsDirectoryCoordinatorBridgePresenterDelegate, RoomNotificationSettingsCoordinatorBridgePresenterDelegate, DialpadViewControllerDelegate, ExploreRoomCoordinatorBridgePresenterDelegate, SpaceChildRoomDetailBridgePresenterDelegate, RoomContextActionServiceDelegate>
{
// Tell whether a recents refresh is pending (suspended during editing mode).
BOOL isRefreshPending;
@@ -138,6 +138,9 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
displayedSectionHeaders = [NSMutableArray array];
_contextMenuProvider = [RecentCellContextMenuProvider new];
self.contextMenuProvider.serviceDelegate = self;
// Set itself as delegate by default.
self.delegate = self;
}
@@ -364,6 +367,15 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
- (void)refreshRecentsTable
{
MXLogDebug(@"[RecentsViewController]: Refreshing recents table view")
if (!self.recentsUpdateEnabled)
{
isRefreshNeeded = NO;
return;
}
isRefreshNeeded = NO;
// Refresh the tabBar icon badges
[[AppDelegate theDelegate].masterTabBarController refreshTabBarBadges];
@@ -1032,6 +1044,12 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
- (void)dataSource:(MXKDataSource *)dataSource didCellChange:(id)changes
{
if (!self.recentsUpdateEnabled)
{
[super dataSource:dataSource didCellChange:changes];
return;
}
if ([changes isKindOfClass:NSIndexPath.class])
{
NSIndexPath *indexPath = (NSIndexPath *)changes;
@@ -2487,4 +2505,78 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
}
}
#pragma mark - Context Menu
- (UIContextMenuConfiguration *)tableView:(UITableView *)tableView contextMenuConfigurationForRowAtIndexPath:(NSIndexPath *)indexPath point:(CGPoint)point API_AVAILABLE(ios(13.0))
{
id<MXKRecentCellDataStoring> cellData = [self.dataSource cellDataAtIndexPath:indexPath];
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
if (!cellData || !cell)
{
return nil;
}
self.recentsUpdateEnabled = NO;
return [self.contextMenuProvider contextMenuConfigurationWith:cellData from:cell session:self.dataSource.mxSession];
}
- (void)tableView:(UITableView *)tableView willPerformPreviewActionForMenuWithConfiguration:(UIContextMenuConfiguration *)configuration animator:(id<UIContextMenuInteractionCommitAnimating>)animator API_AVAILABLE(ios(13.0))
{
NSString *roomId = [self.contextMenuProvider roomIdFrom:configuration.identifier];
if (!roomId)
{
self.recentsUpdateEnabled = YES;
return;
}
[animator addCompletion:^{
self.recentsUpdateEnabled = YES;
[self showRoomWithRoomId:roomId inMatrixSession:self.mainSession];
}];
}
- (UITargetedPreview *)tableView:(UITableView *)tableView previewForDismissingContextMenuWithConfiguration:(UIContextMenuConfiguration *)configuration API_AVAILABLE(ios(13.0))
{
self.recentsUpdateEnabled = YES;
return nil;
}
#pragma mark - RoomContextActionServiceDelegate
- (void)roomContextActionServiceDidJoinRoom:(id<RoomContextActionServiceProtocol>)service
{
[self showRoomWithRoomId:service.roomId inMatrixSession:service.session];
}
- (void)roomContextActionServiceDidLeaveRoom:(id<RoomContextActionServiceProtocol>)service
{
[self.userIndicatorStore presentSuccessWithLabel:VectorL10n.roomParticipantsLeaveSuccess];
}
- (void)roomContextActionService:(id<RoomContextActionServiceProtocol>)service presentAlert:(UIAlertController *)alertController
{
[self presentViewController:alertController animated:YES completion:nil];
}
- (void)roomContextActionService:(id<RoomContextActionServiceProtocol>)service updateActivityIndicator:(BOOL)isActive
{
if (isActive)
{
[self startActivityIndicator];
}
else if ([self canStopActivityIndicator])
{
[self stopActivityIndicator];
}
}
- (void)roomContextActionService:(id<RoomContextActionServiceProtocol>)service showRoomNotificationSettingsForRoomWithId:(NSString *)roomId
{
editedRoomId = roomId;
[self changeEditedRoomNotificationSettings];
editedRoomId = nil;
}
@end