mattermost-mobile/patches/react-native-navigation+2.21.1.patch
Miguel Alatzar 459801d10b
[MM-17560] Await dismissAllModals and popToRoot prior to calling showSearchModal (#3298)
* Patch react-native-navigation

* Make navigation actions regular functions

* Fix unhandled promise rejection warning

* Missing semicolons

* Mock navigation actions

* Add unit tests for navigation actions

* Place all patches in patches directory

* Fix channel_info snapshot test
2019-09-25 15:23:45 -07:00

102 lines
5.3 KiB
Diff

diff --git a/node_modules/react-native-navigation/lib/ios/RNNCommandsHandler.m b/node_modules/react-native-navigation/lib/ios/RNNCommandsHandler.m
index 91b878d..9cd61d5 100644
--- a/node_modules/react-native-navigation/lib/ios/RNNCommandsHandler.m
+++ b/node_modules/react-native-navigation/lib/ios/RNNCommandsHandler.m
@@ -72,7 +72,7 @@ - (void)setRoot:(NSDictionary*)layout commandId:(NSString*)commandId completion:
}
}
- [_modalManager dismissAllModalsAnimated:NO];
+ [_modalManager dismissAllModalsAnimated:NO completion:nil];
UIViewController *vc = [_controllerFactory createLayout:layout[@"root"]];
@@ -286,10 +286,9 @@ - (void)dismissAllModals:(NSDictionary *)mergeOptions commandId:(NSString*)comma
[CATransaction begin];
[CATransaction setCompletionBlock:^{
[_eventEmitter sendOnNavigationCommandCompletion:dismissAllModals commandId:commandId params:@{}];
- completion();
}];
RNNNavigationOptions* options = [[RNNNavigationOptions alloc] initWithDict:mergeOptions];
- [_modalManager dismissAllModalsAnimated:[options.animations.dismissModal.enable getWithDefaultValue:YES]];
+ [_modalManager dismissAllModalsAnimated:[options.animations.dismissModal.enable getWithDefaultValue:YES] completion:completion];
[CATransaction commit];
}
diff --git a/node_modules/react-native-navigation/lib/ios/RNNModalManager.h b/node_modules/react-native-navigation/lib/ios/RNNModalManager.h
index 9809db0..a602c92 100644
--- a/node_modules/react-native-navigation/lib/ios/RNNModalManager.h
+++ b/node_modules/react-native-navigation/lib/ios/RNNModalManager.h
@@ -19,6 +19,6 @@ typedef void (^RNNTransitionRejectionBlock)(NSString *code, NSString *message, N
- (void)showModal:(UIViewController *)viewController animated:(BOOL)animated completion:(RNNTransitionWithComponentIdCompletionBlock)completion;
- (void)showModal:(UIViewController *)viewController animated:(BOOL)animated hasCustomAnimation:(BOOL)hasCustomAnimation completion:(RNNTransitionWithComponentIdCompletionBlock)completion;
- (void)dismissModal:(UIViewController *)viewController completion:(RNNTransitionCompletionBlock)completion;
-- (void)dismissAllModalsAnimated:(BOOL)animated;
+- (void)dismissAllModalsAnimated:(BOOL)animated completion:(RNNTransitionCompletionBlock)completion;
@end
diff --git a/node_modules/react-native-navigation/lib/ios/RNNModalManager.m b/node_modules/react-native-navigation/lib/ios/RNNModalManager.m
index 18c0eb8..a404da7 100644
--- a/node_modules/react-native-navigation/lib/ios/RNNModalManager.m
+++ b/node_modules/react-native-navigation/lib/ios/RNNModalManager.m
@@ -50,9 +50,16 @@ - (void)dismissModal:(UIViewController *)viewController completion:(RNNTransitio
}
}
--(void)dismissAllModalsAnimated:(BOOL)animated {
+-(void)dismissAllModalsAnimated:(BOOL)animated completion:(RNNTransitionCompletionBlock)completion {
+ if (!_presentedModals || !_presentedModals.count) {
+ if (completion) {
+ completion();
+ }
+ return;
+ }
+
UIViewController *root = UIApplication.sharedApplication.delegate.window.rootViewController;
- [root dismissViewControllerAnimated:animated completion:nil];
+ [root dismissViewControllerAnimated:animated completion:completion];
[_delegate dismissedMultipleModals:_presentedModals];
[_pendingModalIdsToDismiss removeAllObjects];
[_presentedModals removeAllObjects];
diff --git a/node_modules/react-native-navigation/lib/ios/ReactNativeNavigation.xcodeproj/xcuserdata/miguel.xcuserdatad/xcschemes/xcschememanagement.plist b/node_modules/react-native-navigation/lib/ios/ReactNativeNavigation.xcodeproj/xcuserdata/miguel.xcuserdatad/xcschemes/xcschememanagement.plist
new file mode 100644
index 0000000..a2f2607
--- /dev/null
+++ b/node_modules/react-native-navigation/lib/ios/ReactNativeNavigation.xcodeproj/xcuserdata/miguel.xcuserdatad/xcschemes/xcschememanagement.plist
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>SchemeUserState</key>
+ <dict>
+ <key>ReactNativeNavigation.xcscheme_^#shared#^_</key>
+ <dict>
+ <key>orderHint</key>
+ <integer>6</integer>
+ </dict>
+ </dict>
+</dict>
+</plist>
diff --git a/node_modules/react-native-navigation/lib/ios/ReactNativeNavigationTests/RNNModalManagerTest.m b/node_modules/react-native-navigation/lib/ios/ReactNativeNavigationTests/RNNModalManagerTest.m
index 407051a..8f02aae 100644
--- a/node_modules/react-native-navigation/lib/ios/ReactNativeNavigationTests/RNNModalManagerTest.m
+++ b/node_modules/react-native-navigation/lib/ios/ReactNativeNavigationTests/RNNModalManagerTest.m
@@ -51,7 +51,7 @@ - (void)testDismissMultipleModalsInvokeDelegateWithCorrectParameters {
[_modalManager showModal:_vc3 animated:NO completion:nil];
_modalManager.delegate = self;
- [_modalManager dismissAllModalsAnimated:NO];
+ [_modalManager dismissAllModalsAnimated:NO completion:nil];
XCTAssertTrue(_modalDismissedCount == 3);
}
@@ -87,7 +87,7 @@ - (void)testDismissAllModals_AfterDismissingPreviousModal_InvokeDelegateWithCorr
[_modalManager dismissModal:_vc2 completion:nil];
XCTAssertTrue(_modalDismissedCount == 1);
- [_modalManager dismissAllModalsAnimated:NO];
+ [_modalManager dismissAllModalsAnimated:NO completion:nil];
XCTAssertTrue(_modalDismissedCount == 2);
}