@@ -320,6 +320,36 @@ final class SideMenuCoordinator: NSObject, SideMenuCoordinatorType {
320
320
self . spaceSettingsCoordinator = coordinator
321
321
}
322
322
323
+ func showSpaceInvite( spaceId: String , session: MXSession ) {
324
+ guard let space = session. spaceService. getSpace ( withId: spaceId) , let spaceRoom = space. room else {
325
+ MXLog . error ( " [SideMenuCoordinator] showSpaceInvite: failed to find space with id \( spaceId) " )
326
+ return
327
+ }
328
+
329
+ spaceRoom. state { [ weak self] roomState in
330
+ guard let self = self else { return }
331
+
332
+ guard let powerLevels = roomState? . powerLevels, let userId = session. myUserId else {
333
+ MXLog . error ( " [SpaceMembersCoordinator] spaceMemberListCoordinatorShowInvite: failed to find powerLevels for room " )
334
+ return
335
+ }
336
+ let userPowerLevel = powerLevels. powerLevelOfUser ( withUserID: userId)
337
+
338
+ guard userPowerLevel >= powerLevels. invite else {
339
+ let alert = UIAlertController ( title: VectorL10n . spacesInvitePeople, message: VectorL10n . spaceInviteNotEnoughPermission, preferredStyle: . alert)
340
+ alert. addAction ( UIAlertAction ( title: VectorL10n . ok, style: . default, handler: nil ) )
341
+ self . sideMenuViewController. present ( alert, animated: true )
342
+ return
343
+ }
344
+
345
+ let coordinator = ContactsPickerCoordinator ( session: session, room: spaceRoom, initialSearchText: nil , actualParticipants: nil , invitedParticipants: nil , userParticipant: nil )
346
+ coordinator. delegate = self
347
+ coordinator. start ( )
348
+ self . add ( childCoordinator: coordinator)
349
+ self . sideMenuViewController. present ( coordinator. toPresentable ( ) , animated: true )
350
+ }
351
+ }
352
+
323
353
private func resetExploringSpaceIfNeeded( ) {
324
354
if sideMenuNavigationViewController. presentedViewController == nil {
325
355
Analytics . shared. exploringSpace = nil
@@ -437,6 +467,8 @@ extension SideMenuCoordinator: SpaceMenuPresenterDelegate {
437
467
} else {
438
468
AppDelegate . theDelegate ( ) . showAlert ( withTitle: VectorL10n . settingsTitle, message: VectorL10n . spacesComingSoonDetail ( AppInfo . current. displayName) )
439
469
}
470
+ case . invite:
471
+ self . showSpaceInvite ( spaceId: spaceId, session: session)
440
472
}
441
473
}
442
474
}
@@ -511,6 +543,19 @@ extension SideMenuCoordinator: CreateRoomCoordinatorDelegate {
511
543
}
512
544
}
513
545
546
+ // MARK: - ContactsPickerCoordinatorDelegate
547
+ extension SideMenuCoordinator : ContactsPickerCoordinatorDelegate {
548
+ func contactsPickerCoordinatorDidStartLoading( _ coordinator: ContactsPickerCoordinatorProtocol ) {
549
+ }
550
+
551
+ func contactsPickerCoordinatorDidEndLoading( _ coordinator: ContactsPickerCoordinatorProtocol ) {
552
+ }
553
+
554
+ func contactsPickerCoordinatorDidClose( _ coordinator: ContactsPickerCoordinatorProtocol ) {
555
+ remove ( childCoordinator: coordinator)
556
+ }
557
+ }
558
+
514
559
// MARK: - UIAdaptivePresentationControllerDelegate
515
560
extension SideMenuCoordinator : UIAdaptivePresentationControllerDelegate {
516
561
0 commit comments