MESSENGER-5304 add room federation decision sheet

This commit is contained in:
JanNiklas Grabowski
2024-01-23 16:11:04 +01:00
parent 3a9d084f2d
commit e4ca351f31
5 changed files with 279 additions and 2 deletions
+33
View File
@@ -242,6 +242,9 @@ static CGSize kThreadListBarButtonItemImageSize;
// Check if we should wait for other participants
@property (nonatomic, readonly) BOOL shouldWaitForOtherParticipants;
// bwi: #5304 show federation decision sheet
@property (nonatomic) BOOL wasFederationDecisionSheetShownBefore;
@end
@implementation RoomViewController
@@ -434,6 +437,9 @@ static CGSize kThreadListBarButtonItemImageSize;
[self setupCompletionSuggestionViewIfNeeded];
[self.topBannersStackView vc_removeAllSubviews];
// bwi: #5304 show federation decision sheet
self.wasFederationDecisionSheetShownBefore = false;
}
- (void)userInterfaceThemeDidChange
@@ -717,6 +723,10 @@ static CGSize kThreadListBarButtonItemImageSize;
}
[self setMaximisedToolbarIsHiddenIfNeeded: NO];
// bwi: #5304 show federation decision sheet only for admins and only in rooms / not in DMs
[self showFederationDecisionSheet];
}
- (void)viewDidDisappear:(BOOL)animated
@@ -8231,6 +8241,29 @@ static CGSize kThreadListBarButtonItemImageSize;
}
}
#pragma mark - BWI Federation
// bwi: #5304 show federation decision sheet only for admins and only in rooms / not in DMs
- (void)showFederationDecisionSheet {
if (!self.wasFederationDecisionSheetShownBefore && BWIBuildSettings.shared.isFederationEnabled && !self.roomDataSource.room.isDirect)
{
MXRoomPowerLevels *powerLevels = self.roomDataSource.roomState.powerLevels;
if ([powerLevels powerLevelOfUserWithUserID:self.mainSession.myUser.userId] == RoomPowerLevelAdmin)
{
[self.roomDataSource.room getCurrentRoomServerACLSettingsWithCompletion:^(NSString *serverACL)
{
if (serverACL == nil) {
self.wasFederationDecisionSheetShownBefore = true;
RoomFederationDecisionSheet *federationDecisionView = [[RoomFederationDecisionSheet alloc] init];
UIViewController *sheetViewController = [federationDecisionView makeViewControllerWithRoom:self.roomDataSource.room roomAvatarImage: ((RoomTitleView*)self.titleView).pictureView.image];
sheetViewController.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentViewController:sheetViewController animated:YES completion:nil];
}
}];
}
}
}
#pragma mark - UserSuggestionCoordinatorBridgeDelegate
- (void)completionSuggestionCoordinatorBridge:(CompletionSuggestionCoordinatorBridge *)coordinator