@@ -308,7 +308,7 @@ + (void)processLinkURL:(NSURL * _Nullable)url {
308
308
case URLTypeNewSignUpLink: {
309
309
if ([SAMKeychain passwordForService: @" MEGA" account: @" sessionV3" ]) {
310
310
[MEGALinkManager resetLinkAndURLType ];
311
-
311
+
312
312
UIAlertController *alreadyLoggedInAlertController = [UIAlertController alertControllerWithTitle: LocalizedString (@" error" , @" " ) message: LocalizedString (@" This link is not related to this account. Please log in with the correct account." , @" Error message shown when opening a link with an account that not corresponds to the link" ) preferredStyle: UIAlertControllerStyleAlert];
313
313
[alreadyLoggedInAlertController addAction: [UIAlertAction actionWithTitle: LocalizedString (@" ok" , @" Button title to accept something" ) style: UIAlertActionStyleDestructive handler: nil ]];
314
314
@@ -440,7 +440,7 @@ + (void)processLinkURL:(NSURL * _Nullable)url {
440
440
[mainTBC showAddContact ];
441
441
}
442
442
break ;
443
-
443
+
444
444
case URLTypePresentNode:
445
445
self.nodeToPresentBase64Handle = [url.absoluteString componentsSeparatedByString: @" /" ].lastObject ;
446
446
[self presentNode ];
@@ -606,7 +606,7 @@ + (void)showFileLinkView {
606
606
photoBrowserVC.publicLink = fileLinkURLString;
607
607
photoBrowserVC.encryptedLink = MEGALinkManager.secondaryLinkURL .absoluteString ;
608
608
photoBrowserVC.needsReload = YES ;
609
-
609
+
610
610
[self presentViewControllerWithAds: photoBrowserVC adsSlotViewController: photoBrowserVC presentationStyle: UIModalPresentationAutomatic];
611
611
} else if ([FileExtensionGroupOCWrapper verifyIsMultiMedia: node.name] && node.mnz_isPlayable ) {
612
612
[self initFullScreenPlayerWithNode: node fileLink: fileLinkURLString filePaths: nil isFolderLink: NO isFromSharedItem: NO presenter: UIApplication.mnz_visibleViewController];
@@ -663,7 +663,7 @@ + (void)handleContactLink {
663
663
}
664
664
NSString *contactLinkHandle = [path substringFromIndex: (rangeOfPrefix.location + rangeOfPrefix.length)];
665
665
uint64_t handle = [MEGASdk handleForBase64Handle: contactLinkHandle];
666
-
666
+
667
667
MEGAContactLinkQueryRequestDelegate *delegate = [[MEGAContactLinkQueryRequestDelegate alloc ] initWithCompletion: ^(MEGARequest *request) {
668
668
NSString *fullName = [NSString stringWithFormat: @" %@ %@ " , request.name, request.text];
669
669
[MEGALinkManager presentInviteModalForEmail: request.email fullName: fullName contactLinkHandle: request.nodeHandle image: request.file];
@@ -674,7 +674,7 @@ + (void)handleContactLink {
674
674
} onError: ^(MEGAError *error) {
675
675
[SVProgressHUD showErrorWithStatus: LocalizedString (@" linkNotValid" , @" Message shown when the user clicks on an link that is not valid" )];
676
676
}];
677
-
677
+
678
678
[MEGASdk.shared contactLinkQueryWithHandle: handle delegate: delegate];
679
679
}
680
680
@@ -767,9 +767,22 @@ + (void)handlePublicChatLink {
767
767
}
768
768
} else { // Chat link
769
769
MEGAChatRoom *chatRoom = [MEGAChatSdk.shared chatRoomForChatId: request.chatHandle];
770
- [MEGALinkManager autoRejoinAndOpenChatVCWithChatRoom: chatRoom
771
- request: request
772
- chatLinkUrl: chatLinkUrl];
770
+ if (!chatRoom.isPreview && !chatRoom.isActive ) {
771
+ ChatRequestDelegate *autorejoinPublicChatDelegate = [[ChatRequestDelegate alloc ] initWithCompletion: ^(MEGAChatRequest * _Nonnull request, MEGAChatError * _Nonnull error) {
772
+ if (error.type ) {
773
+ [SVProgressHUD setDefaultMaskType: SVProgressHUDMaskTypeNone];
774
+ [SVProgressHUD showErrorWithStatus: [NSString stringWithFormat: @" %@ %@ " , request.requestString, LocalizedString (error.name, @" " )]];
775
+ return ;
776
+ }
777
+ [MEGALinkManager.joiningOrLeavingChatBase64Handles removeObject: [MEGASdk base64HandleForUserHandle: request.chatHandle]];
778
+ [MEGALinkManager createChatAndShow: request.chatHandle publicChatLink: chatLinkUrl];
779
+ }];
780
+ [MEGAChatSdk.shared autorejoinPublicChat: request.chatHandle publicHandle: request.userHandle delegate: autorejoinPublicChatDelegate];
781
+ [MEGALinkManager.joiningOrLeavingChatBase64Handles addObject: [MEGASdk base64HandleForUserHandle: request.chatHandle]];
782
+ } else {
783
+ [MEGALinkManager createChatAndShow: request.chatHandle publicChatLink: chatLinkUrl];
784
+ }
785
+
773
786
[SVProgressHUD dismiss ];
774
787
}
775
788
}];
@@ -822,30 +835,68 @@ + (void)openMeetingWithRequest:(MEGAChatRequest * _Nonnull)request chatLinkURL:(
822
835
if ([self isHostInWaitingRoomWithRequest: request chatSdk: MEGAChatSdk.shared]) {
823
836
[self joinCallWithRequest: request];
824
837
} else {
825
- [self createMeetingAndShowWithChatId : request.chatHandle userHandle: request.userHandle publicChatLink: chatLinkUrl];
838
+ [self createMeetingAndShow : request.chatHandle userHandle: request.userHandle publicChatLink: chatLinkUrl];
826
839
}
827
- }
828
- else {
829
- // [MEET-2619] we jump straight to chat for ended or not began meetings
840
+ } else {
841
+ // Meeting ended or not yet began
830
842
[SVProgressHUD dismiss ];
831
843
MEGAChatRoom *chatRoom = [[MEGAChatSdk shared ] chatRoomForChatId: request.chatHandle];
832
- if (chatRoom == nil ) {
833
- MEGALogError (@" Cannot join chat, missing chat room %llu " , request.chatHandle );
834
- return ;
844
+ if (!chatRoom.isPreview && !chatRoom.isActive ) {
845
+ ChatRequestDelegate *autorejoinPublicChatDelegate = [[ChatRequestDelegate alloc ] initWithCompletion: ^(MEGAChatRequest * _Nonnull request, MEGAChatError * _Nonnull error) {
846
+ if (error.type ) {
847
+ [SVProgressHUD setDefaultMaskType: SVProgressHUDMaskTypeNone];
848
+ [SVProgressHUD showErrorWithStatus: [NSString stringWithFormat: @" %@ %@ " , request.requestString, LocalizedString (error.name, @" " )]];
849
+ return ;
850
+ }
851
+ [MEGALinkManager.joiningOrLeavingChatBase64Handles removeObject: [MEGASdk base64HandleForUserHandle: request.chatHandle]];
852
+ [MEGALinkManager createChatAndShow: request.chatHandle publicChatLink: chatLinkUrl];
853
+ }];
854
+ [MEGAChatSdk.shared autorejoinPublicChat: request.chatHandle publicHandle: request.userHandle delegate: autorejoinPublicChatDelegate];
855
+ [MEGALinkManager.joiningOrLeavingChatBase64Handles addObject: [MEGASdk base64HandleForUserHandle: request.chatHandle]];
856
+ } else {
857
+ [MEGALinkManager createChatAndShow: request.chatHandle publicChatLink: chatLinkUrl];
835
858
}
836
- [MEGALinkManager autoRejoinAndOpenChatVCWithChatRoom: chatRoom
837
- request: request
838
- chatLinkUrl: chatLinkUrl];
839
859
}
840
860
}
841
861
842
- + (BOOL )isLoggedIn {
862
+ + (void )createMeetingAndShow : (uint64_t )chatId userHandle : (uint64_t )userHandle publicChatLink : (NSURL *)publicChatLink {
863
+
864
+ UIViewController *rootViewController = UIApplication.mnz_keyWindow .rootViewController ;
865
+ MEGAChatRoom *chatRoom = [MEGAChatSdk.shared chatRoomForChatId: chatId];
866
+ if (chatRoom == nil ) {
867
+ return ;
868
+ } else if (MEGAChatSdk.shared .mnz_existsActiveCall ) {
869
+ [MeetingAlreadyExistsAlert showWithPresenter: rootViewController];
870
+ return ;
871
+ }
843
872
844
873
// If the application was deleted when the user is logged and then reinstalled.
845
874
// The sdk says the user is logged in but the session is cleared.
846
875
NSString *sessionV3 = [SAMKeychain passwordForService: @" MEGA" account: @" sessionV3" ];
847
876
BOOL isLoggedIn = MEGASdk.shared .isLoggedIn && sessionV3 != nil && !sessionV3.mnz_isEmpty ;
848
- return isLoggedIn;
877
+ MeetingConfigurationType type = isLoggedIn ? MeetingConfigurationTypeJoin : MeetingConfigurationTypeGuestJoin;
878
+
879
+ if (UIApplication.mainTabBarRootViewController ) {
880
+ MainTabBarController *mainTBC = (MainTabBarController *)UIApplication.mainTabBarRootViewController ;
881
+ mainTBC.selectedIndex = TabTypeChat;
882
+ MeetingCreatingViewRouter *router = [[MeetingCreatingViewRouter alloc ] initWithViewControllerToPresent: mainTBC
883
+ type: type
884
+ link :publicChatLink.absoluteString
885
+ userhandle: userHandle];
886
+ if (mainTBC.presentedViewController ) {
887
+ [mainTBC dismissViewControllerAnimated: NO completion: ^{
888
+ [router start ];
889
+ }];
890
+ } else {
891
+ [router start ];
892
+ }
893
+ } else {
894
+ MeetingCreatingViewRouter *router = [[MeetingCreatingViewRouter alloc ] initWithViewControllerToPresent: UIApplication.mnz_visibleViewController
895
+ type: type
896
+ link :publicChatLink.absoluteString
897
+ userhandle: userHandle];
898
+ [router start ];
899
+ }
849
900
}
850
901
851
902
+ (void )createChatAndShow : (uint64_t )chatId publicChatLink : (NSURL *)publicChatLink {
@@ -877,14 +928,12 @@ + (void)createChatAndShow:(uint64_t)chatId publicChatLink:(NSURL *)publicChatLin
877
928
} else {
878
929
// there's no UINavigationController present when user is logged out
879
930
// we do a present in that case
880
- UIViewController *presenter = UIApplication.mnz_visibleViewController ;
881
- BOOL shouldPush = [presenter isKindOfClass: [UINavigationController class ]];
882
- ChatContentRouter *router = [[ChatContentRouter alloc ] initWithChatRoom: chatRoom
883
- presenter: presenter
884
- publicLink: publicChatLink.absoluteString
885
- showShareLinkViewAfterOpenChat: NO
886
- chatContentRoutingStyle: shouldPush ? ChatContentRoutingStylePush : ChatContentRoutingStylePresent];
887
- [router start ];
931
+ [[ChatContentRouter.alloc initWithChatRoom: chatRoom
932
+ presenter: UIApplication.mnz_visibleViewController
933
+ publicLink: publicChatLink.absoluteString
934
+ showShareLinkViewAfterOpenChat: NO
935
+ chatContentRoutingStyle: ChatContentRoutingStylePresent
936
+ ] start ];
888
937
}
889
938
}
890
939
@@ -899,7 +948,12 @@ + (void)pushChat:(MEGAChatRoom *)chatRoom publicChatLink:(NSURL *)publicChatLink
899
948
}
900
949
901
950
[chatNC popToRootViewControllerAnimated: NO ];
902
- [[ChatContentRouter.alloc initWithChatRoom: chatRoom presenter: chatNC publicLink: publicChatLink.absoluteString showShareLinkViewAfterOpenChat: NO chatContentRoutingStyle: ChatContentRoutingStylePush] start ];
951
+ [[ChatContentRouter.alloc initWithChatRoom: chatRoom
952
+ presenter: chatNC
953
+ publicLink: publicChatLink.absoluteString
954
+ showShareLinkViewAfterOpenChat: NO
955
+ chatContentRoutingStyle: ChatContentRoutingStylePush
956
+ ] start ];
903
957
}
904
958
905
959
+ (void )handleChatPeerOptionsLink {
0 commit comments