Browse Source

Fix dismissAllModal API - the root won't unregister when invoke dismissAllModals (#2255)

Ran Greenberg 7 years ago
parent
commit
b0eeeccf36
No account linked to committer's email address
1 changed files with 7 additions and 1 deletions
  1. 7
    1
      ios/RCCManagerModule.m

+ 7
- 1
ios/RCCManagerModule.m View File

142
 
142
 
143
 -(void)dismissAllModalPresenters:(NSMutableArray*)allPresentedViewControllers resolver:(RCTPromiseResolveBlock)resolve
143
 -(void)dismissAllModalPresenters:(NSMutableArray*)allPresentedViewControllers resolver:(RCTPromiseResolveBlock)resolve
144
 {
144
 {
145
+    UIViewController *rootViewController = [UIApplication sharedApplication].delegate.window.rootViewController;
146
+
145
     if (allPresentedViewControllers.count > 0)
147
     if (allPresentedViewControllers.count > 0)
146
     {
148
     {
147
         dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),^
149
         dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),^
151
                            {
153
                            {
152
                                counter++;
154
                                counter++;
153
                                
155
                                
154
-                               [[RCCManager sharedIntance] unregisterController:viewController];
156
+                               
155
                                if (viewController.presentedViewController != nil)
157
                                if (viewController.presentedViewController != nil)
156
                                {
158
                                {
157
                                    dispatch_semaphore_t dismiss_sema = dispatch_semaphore_create(0);
159
                                    dispatch_semaphore_t dismiss_sema = dispatch_semaphore_create(0);
160
                                                   {
162
                                                   {
161
                                                       [viewController dismissViewControllerAnimated:NO completion:^()
163
                                                       [viewController dismissViewControllerAnimated:NO completion:^()
162
                                                        {
164
                                                        {
165
+                                                           if (rootViewController != viewController) {
166
+                                                               [[RCCManager sharedIntance] unregisterController:viewController];
167
+                                                           }
168
+                                                           
163
                                                            if (counter == allPresentedViewControllers.count && allPresentedViewControllers.count > 0)
169
                                                            if (counter == allPresentedViewControllers.count && allPresentedViewControllers.count > 0)
164
                                                            {
170
                                                            {
165
                                                                [allPresentedViewControllers removeAllObjects];
171
                                                                [allPresentedViewControllers removeAllObjects];