Browse Source

Always resolve dismissAllModals promise (#6054)

When no modals are displayed and dismissAllModals is called, resolve the promise successfully. This regression was introduced in #5991
Guy Carmeli 4 years ago
parent
commit
ec03383b0d
No account linked to committer's email address

+ 1
- 0
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/modal/ModalStack.java View File

84
 
84
 
85
     public void dismissAllModals(ViewController root, Options mergeOptions, CommandListener listener) {
85
     public void dismissAllModals(ViewController root, Options mergeOptions, CommandListener listener) {
86
         if (modals.isEmpty()) {
86
         if (modals.isEmpty()) {
87
+            listener.onSuccess(root.getId());
87
             return;
88
             return;
88
         }
89
         }
89
         String topModalId = peek().getId();
90
         String topModalId = peek().getId();

+ 7
- 0
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/modal/ModalStackTest.java View File

173
         verifyZeroInteractions(listener);
173
         verifyZeroInteractions(listener);
174
     }
174
     }
175
 
175
 
176
+    @Test
177
+    public void dismissAllModals_resolveSuccessfullyIfEmpty() {
178
+        CommandListener spy = spy(new CommandListenerAdapter());
179
+        uut.dismissAllModals(root, Options.EMPTY, spy);
180
+        verify(spy, times(1)).onSuccess(root.getId());
181
+    }
182
+
176
     @Test
183
     @Test
177
     public void dismissAllModals_optionsAreMergedOnTopModal() {
184
     public void dismissAllModals_optionsAreMergedOnTopModal() {
178
         uut.showModal(modal1, root, new CommandListenerAdapter());
185
         uut.showModal(modal1, root, new CommandListenerAdapter());

+ 1
- 0
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/navigator/NavigatorTest.java View File

596
     public void dismissAllModals_onViewAppearedInvokedOnRoot() {
596
     public void dismissAllModals_onViewAppearedInvokedOnRoot() {
597
         disablePushAnimation(child2);
597
         disablePushAnimation(child2);
598
         disableShowModalAnimation(child1);
598
         disableShowModalAnimation(child1);
599
+        uut.setRoot(child3, new CommandListenerAdapter(), reactInstanceManager);
599
 
600
 
600
         uut.dismissAllModals(Options.EMPTY, new CommandListenerAdapter());
601
         uut.dismissAllModals(Options.EMPTY, new CommandListenerAdapter());
601
         verify(parentVisibilityListener, times(0)).onViewAppeared(parentController.getView());
602
         verify(parentVisibilityListener, times(0)).onViewAppeared(parentController.getView());