Skip to content

Commit

Permalink
Fixes command completion event commandId (#4766)
Browse files Browse the repository at this point in the history
* Fixes command completion event commandId

* Fix e2e
  • Loading branch information
yogevbd authored Mar 24, 2019
1 parent 1c740b7 commit 0e29a03
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 82 deletions.
6 changes: 3 additions & 3 deletions e2e/StaticLifecycleEvents.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('static lifecycle events', () => {
await expect(elementByLabel('componentDidDisappear | EventsScreen')).toBeVisible();
});

it(':ios: pushing and popping screen dispatch static event', async () => {
it('pushing and popping screen dispatch static event', async () => {
await expect(elementByLabel('Static Lifecycle Events Overlay')).toBeVisible();
await expect(elementByLabel('componentDidAppear | EventsOverlay')).toBeVisible();
await elementById(TestIDs.PUSH_BTN).tap();
Expand All @@ -26,14 +26,14 @@ describe('static lifecycle events', () => {
await expect(elementByLabel('pop')).toBeVisible();
});

it(':ios: showModal and dismissModal dispatch static event', async () => {
it('showModal and dismissModal dispatch static event', async () => {
await elementById(TestIDs.MODAL_BTN).tap();
await expect(elementByLabel('showModal')).toBeVisible();
await elementById(TestIDs.DISMISS_MODAL_BTN).tap();
await expect(elementByLabel('dismissModal')).toBeVisible();
});

it(':ios: unmounts when dismissed', async () => {
it('unmounts when dismissed', async () => {
await elementById(TestIDs.PUSH_BTN).tap();
await expect(elementByLabel('Static Lifecycle Events Overlay')).toBeVisible();
await elementById(TestIDs.DISMISS_BTN).tap();
Expand Down
22 changes: 11 additions & 11 deletions lib/ios/RNNBridgeModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ -(instancetype)initWithCommandsHandler:(RNNCommandsHandler *)commandsHandler {
#pragma mark - JS interface

RCT_EXPORT_METHOD(setRoot:(NSString*)commandId layout:(NSDictionary*)layout resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
[_commandsHandler setRoot:layout completion:^{
[_commandsHandler setRoot:layout commandId:commandId completion:^{
resolve(layout);
}];
}
Expand All @@ -38,61 +38,61 @@ -(instancetype)initWithCommandsHandler:(RNNCommandsHandler *)commandsHandler {
}

RCT_EXPORT_METHOD(push:(NSString*)commandId componentId:(NSString*)componentId layout:(NSDictionary*)layout resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
[_commandsHandler push:componentId layout:layout completion:^{
[_commandsHandler push:componentId commandId:commandId layout:layout completion:^{
resolve(componentId);
} rejection:reject];
}

RCT_EXPORT_METHOD(pop:(NSString*)commandId componentId:(NSString*)componentId mergeOptions:(NSDictionary*)options resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
[_commandsHandler pop:componentId mergeOptions:(NSDictionary*)options completion:^{
[_commandsHandler pop:componentId commandId:commandId mergeOptions:(NSDictionary*)options completion:^{
resolve(componentId);
} rejection:reject];
}

RCT_EXPORT_METHOD(setStackRoot:(NSString*)commandId componentId:(NSString*)componentId children:(NSArray*)children resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
[_commandsHandler setStackRoot:componentId children:children completion:^{
[_commandsHandler setStackRoot:componentId commandId:commandId children:children completion:^{
resolve(componentId);
} rejection:reject];
}

RCT_EXPORT_METHOD(popTo:(NSString*)commandId componentId:(NSString*)componentId mergeOptions:(NSDictionary*)options resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
[_commandsHandler popTo:componentId mergeOptions:options completion:^{
[_commandsHandler popTo:componentId commandId:commandId mergeOptions:options completion:^{
resolve(componentId);
} rejection:reject];
}

RCT_EXPORT_METHOD(popToRoot:(NSString*)commandId componentId:(NSString*)componentId mergeOptions:(NSDictionary*)options resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
[_commandsHandler popToRoot:componentId mergeOptions:options completion:^{
[_commandsHandler popToRoot:componentId commandId:commandId mergeOptions:options completion:^{
resolve(componentId);
} rejection:reject];
}

RCT_EXPORT_METHOD(showModal:(NSString*)commandId layout:(NSDictionary*)layout resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
[_commandsHandler showModal:layout completion:^(NSString *componentId) {
[_commandsHandler showModal:layout commandId:commandId completion:^(NSString *componentId) {
resolve(componentId);
}];
}

RCT_EXPORT_METHOD(dismissModal:(NSString*)commandId componentId:(NSString*)componentId mergeOptions:(NSDictionary*)options resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
[_commandsHandler dismissModal:componentId mergeOptions:options completion:^{
[_commandsHandler dismissModal:componentId commandId:commandId mergeOptions:options completion:^{
resolve(componentId);
} rejection:reject];
}

RCT_EXPORT_METHOD(dismissAllModals:(NSString*)commandId mergeOptions:(NSDictionary*)options resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
[_commandsHandler dismissAllModals:options completion:^{
[_commandsHandler dismissAllModals:options commandId:commandId completion:^{
resolve(nil);
}];
}

RCT_EXPORT_METHOD(showOverlay:(NSString*)commandId layout:(NSDictionary*)layout resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
[_commandsHandler showOverlay:layout completion:^{
[_commandsHandler showOverlay:layout commandId:commandId completion:^{
resolve(layout[@"id"]);
}];
}

RCT_EXPORT_METHOD(dismissOverlay:(NSString*)commandId componentId:(NSString*)componentId resolve:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
[_commandsHandler dismissOverlay:componentId completion:^{
[_commandsHandler dismissOverlay:componentId commandId:commandId completion:^{
resolve(@(1));
} rejection:reject];
}
Expand Down
22 changes: 11 additions & 11 deletions lib/ios/RNNCommandsHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,30 @@

- (instancetype)initWithStore:(RNNStore*)store controllerFactory:(RNNControllerFactory*)controllerFactory eventEmitter:(RNNEventEmitter *)eventEmitter stackManager:(RNNNavigationStackManager *)stackManager modalManager:(RNNModalManager *)modalManager overlayManager:(RNNOverlayManager *)overlayManager mainWindow:(UIWindow *)mainWindow;

- (void)setRoot:(NSDictionary*)layout completion:(RNNTransitionCompletionBlock)completion;
- (void)setRoot:(NSDictionary*)layout commandId:(NSString*)commandId completion:(RNNTransitionCompletionBlock)completion;

- (void)mergeOptions:(NSString*)componentId options:(NSDictionary*)options completion:(RNNTransitionCompletionBlock)completion;

- (void)setDefaultOptions:(NSDictionary*)options completion:(RNNTransitionCompletionBlock)completion;

- (void)push:(NSString*)componentId layout:(NSDictionary*)layout completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection;
- (void)push:(NSString*)componentId commandId:(NSString*)commandId layout:(NSDictionary*)layout completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection;

- (void)pop:(NSString*)componentId mergeOptions:(NSDictionary*)options completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection;
- (void)pop:(NSString*)componentId commandId:(NSString*)commandId mergeOptions:(NSDictionary*)options completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection;

- (void)popTo:(NSString*)componentId mergeOptions:(NSDictionary*)options completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection;
- (void)popTo:(NSString*)componentId commandId:(NSString*)commandId mergeOptions:(NSDictionary*)options completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection;

- (void)popToRoot:(NSString*)componentId mergeOptions:(NSDictionary*)options completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection;
- (void)popToRoot:(NSString*)componentId commandId:(NSString*)commandId mergeOptions:(NSDictionary*)options completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection;

- (void)setStackRoot:(NSString*)componentId children:(NSArray*)children completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection;
- (void)setStackRoot:(NSString*)componentId commandId:(NSString*)commandId children:(NSArray*)children completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection;

- (void)showModal:(NSDictionary*)layout completion:(RNNTransitionWithComponentIdCompletionBlock)completion;
- (void)showModal:(NSDictionary*)layout commandId:(NSString*)commandId completion:(RNNTransitionWithComponentIdCompletionBlock)completion;

- (void)dismissModal:(NSString*)componentId mergeOptions:(NSDictionary*)options completion:(RNNTransitionCompletionBlock)completion rejection:(RNNTransitionRejectionBlock)reject;
- (void)dismissModal:(NSString*)componentId commandId:(NSString*)commandId mergeOptions:(NSDictionary*)options completion:(RNNTransitionCompletionBlock)completion rejection:(RNNTransitionRejectionBlock)reject;

- (void)dismissAllModals:(NSDictionary *)options completion:(RNNTransitionCompletionBlock)completion;
- (void)dismissAllModals:(NSDictionary *)options commandId:(NSString*)commandId completion:(RNNTransitionCompletionBlock)completion;

- (void)showOverlay:(NSDictionary *)layout completion:(RNNTransitionCompletionBlock)completion;
- (void)showOverlay:(NSDictionary *)layout commandId:(NSString*)commandId completion:(RNNTransitionCompletionBlock)completion;

- (void)dismissOverlay:(NSString*)componentId completion:(RNNTransitionCompletionBlock)completion rejection:(RNNTransitionRejectionBlock)reject;
- (void)dismissOverlay:(NSString*)componentId commandId:(NSString*)commandId completion:(RNNTransitionCompletionBlock)completion rejection:(RNNTransitionRejectionBlock)reject;

@end
Loading

0 comments on commit 0e29a03

Please sign in to comment.