Ver código fonte

Fix main menu not showing on first login

Signed-off-by: Philippe Weidmann <philippe.weidmann@infomaniak.com>
Philippe Weidmann 5 anos atrás
pai
commit
8d6cfcab76

+ 1 - 1
iOSClient/AppDelegate.m

@@ -872,7 +872,7 @@ PKPushRegistry *pushRegistry;
     tableDirectory *tableDirectory = [[NCManageDatabase sharedInstance] getTableDirectoryWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND serverUrl == %@", self.activeAccount, self.activeMain.serverUrl]];
     
     if ([tableDirectory.permissions containsString:@"CK"]) {
-        [self showMenuInViewController:self.window.rootViewController];
+        [self showMenuInViewController:[UIViewController topViewControllerWithRootViewController:self.window.rootViewController]];
     } else {
         [[NCContentPresenter shared] messageNotification:@"_warning_" description:@"_no_permission_add_file_" delay:k_dismissAfterSecond type:messageTypeInfo errorCode:0];
     }

+ 23 - 0
iOSClient/Main/MainMenu/MainMenuManager.swift

@@ -282,3 +282,26 @@ extension CCMain {
         return actions
     }
 }
+
+extension UIViewController {
+    @objc class func topViewController(rootViewController: UIViewController?) -> UIViewController? {
+        guard let rootViewController = rootViewController else {
+            return nil
+        }
+
+        guard let presented = rootViewController.presentedViewController else {
+            return rootViewController
+        }
+
+        switch presented {
+        case let navigationController as UINavigationController:
+            return topViewController(rootViewController: navigationController.viewControllers.last)
+
+        case let tabBarController as UITabBarController:
+            return topViewController(rootViewController: tabBarController.selectedViewController)
+
+        default:
+            return topViewController(rootViewController: presented)
+        }
+    }
+}