Skip to content

Commit

Permalink
revert: Update RNSScreenStack.mm
Browse files Browse the repository at this point in the history
  • Loading branch information
hirbod authored and kkafar committed Sep 26, 2024
1 parent 01a9932 commit c9e31d8
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions ios/RNSScreenStack.mm
Original file line number Diff line number Diff line change
Expand Up @@ -686,9 +686,7 @@ - (void)dismissOnReload
#ifdef RCT_NEW_ARCH_ENABLED
#else
dispatch_async(dispatch_get_main_queue(), ^{
[self dismissAllPresentedViewControllersFrom:self->_controller completion:^{
[self invalidate];
}];
[self invalidate];
});
#endif // RCT_NEW_ARCH_ENABLED
}
Expand Down Expand Up @@ -1195,16 +1193,18 @@ - (void)prepareForRecycle

- (void)invalidate {
_invalidated = YES;
[_presentedModals removeAllObjects];
[_controller willMoveToParentViewController:nil];
[_controller removeFromParentViewController];
[self dismissAllPresentedViewControllersFrom:_controller completion:^{
// Ensure presented modals are removed and the controller is detached from its parent
[self->_presentedModals removeAllObjects];
[self->_controller willMoveToParentViewController:nil];
[self->_controller removeFromParentViewController];
}];
}

- (void)dismissAllPresentedViewControllersFrom:(UIViewController *)viewController completion:(void (^)(void))completion {
if (viewController.presentedViewController) {
[viewController.presentedViewController dismissViewControllerAnimated:NO completion:^{
[self dismissAllPresentedViewControllersFrom:viewController completion:completion];
[self invalidate];
}];
} else {
completion();
Expand Down

0 comments on commit c9e31d8

Please sign in to comment.