瀏覽代碼

Stop rejecting on dismissAllModals if no modals are displayed (#5991)

This commit adds parity with iOS which does not reject the promise if dismissAllModals is called while no modals are displayed.
Guy Carmeli 4 年之前
父節點
當前提交
30b0b47b71
No account linked to committer's email address

+ 0
- 2
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/modal/ModalStack.java 查看文件

@@ -84,10 +84,8 @@ public class ModalStack {
84 84
 
85 85
     public void dismissAllModals(ViewController root, Options mergeOptions, CommandListener listener) {
86 86
         if (modals.isEmpty()) {
87
-            listener.onError("Nothing to dismiss");
88 87
             return;
89 88
         }
90
-
91 89
         String topModalId = peek().getId();
92 90
         String topModalName = peek().getCurrentComponentName();
93 91
         int modalsDismissed = size();

+ 5
- 10
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/modal/ModalStackTest.java 查看文件

@@ -1,11 +1,11 @@
1 1
 package com.reactnativenavigation.viewcontrollers.modal;
2 2
 
3 3
 import android.app.Activity;
4
-import androidx.coordinatorlayout.widget.CoordinatorLayout;
5 4
 import android.view.ViewGroup;
6 5
 import android.widget.FrameLayout;
7 6
 
8
-import com.reactnativenavigation.*;
7
+import com.reactnativenavigation.BaseTest;
8
+import com.reactnativenavigation.TestUtils;
9 9
 import com.reactnativenavigation.anim.ModalAnimator;
10 10
 import com.reactnativenavigation.mocks.SimpleViewController;
11 11
 import com.reactnativenavigation.parse.Options;
@@ -14,13 +14,15 @@ import com.reactnativenavigation.utils.CommandListener;
14 14
 import com.reactnativenavigation.utils.CommandListenerAdapter;
15 15
 import com.reactnativenavigation.viewcontrollers.ChildControllersRegistry;
16 16
 import com.reactnativenavigation.viewcontrollers.ViewController;
17
-import com.reactnativenavigation.viewcontrollers.stack.*;
17
+import com.reactnativenavigation.viewcontrollers.stack.StackController;
18 18
 
19 19
 import org.junit.Test;
20 20
 import org.mockito.Mockito;
21 21
 
22 22
 import java.util.EmptyStackException;
23 23
 
24
+import androidx.coordinatorlayout.widget.CoordinatorLayout;
25
+
24 26
 import static org.assertj.core.api.Java6Assertions.assertThat;
25 27
 import static org.assertj.core.api.Java6Assertions.assertThatThrownBy;
26 28
 import static org.mockito.ArgumentMatchers.any;
@@ -171,13 +173,6 @@ public class ModalStackTest extends BaseTest {
171 173
         verifyZeroInteractions(listener);
172 174
     }
173 175
 
174
-    @Test
175
-    public void dismissAllModals_rejectIfEmpty() {
176
-        CommandListener spy = spy(new CommandListenerAdapter());
177
-        uut.dismissAllModals(root, Options.EMPTY, spy);
178
-        verify(spy, times(1)).onError(any());
179
-    }
180
-
181 176
     @Test
182 177
     public void dismissAllModals_optionsAreMergedOnTopModal() {
183 178
         uut.showModal(modal1, root, new CommandListenerAdapter());