Skip to content

Commit d5ec25b

Browse files
SalmaAliSalmaAli
authored andcommitted
🐛 fix bug where setting multiple invocation events only works for the last event passed as a param
1 parent 78d106c commit d5ec25b

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@
7474
*/
7575
public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule {
7676

77+
private static final String TAG = RNInstabugReactnativeModule.class.getSimpleName();
78+
7779
//InvocationEvents
7880
private final String INVOCATION_EVENT_NONE = "none";
7981
private final String INVOCATION_EVENT_SHAKE = "shake";
@@ -769,31 +771,37 @@ public void setInvocationEvent(String invocationEventValue) {
769771
*/
770772
@ReactMethod
771773
public void setInvocationEvents(ReadableArray invocationEventValues) {
774+
772775
try {
773776
Object[] objectArray = ArrayUtil.toArray(invocationEventValues);
774777
String[] stringArray = Arrays.copyOf(objectArray, objectArray.length, String[].class);
778+
ArrayList<InstabugInvocationEvent> parsedInvocationEvents = new ArrayList<>();
779+
780+
Log.d(TAG, Arrays.toString(stringArray) + " " + INVOCATION_EVENT_FLOATING_BUTTON);
781+
775782
for (String action : stringArray) {
776783
switch (action) {
777784
case INVOCATION_EVENT_FLOATING_BUTTON:
778-
BugReporting.setInvocationEvents(InstabugInvocationEvent.FLOATING_BUTTON);
779-
return;
785+
parsedInvocationEvents.add(InstabugInvocationEvent.FLOATING_BUTTON);
786+
break;
780787
case INVOCATION_EVENT_TWO_FINGERS_SWIPE:
781-
BugReporting.setInvocationEvents(InstabugInvocationEvent.TWO_FINGER_SWIPE_LEFT);
788+
parsedInvocationEvents.add(InstabugInvocationEvent.TWO_FINGER_SWIPE_LEFT);
782789
break;
783790
case INVOCATION_EVENT_SHAKE:
784-
BugReporting.setInvocationEvents(InstabugInvocationEvent.SHAKE);
791+
parsedInvocationEvents.add(InstabugInvocationEvent.SHAKE);
785792
break;
786793
case INVOCATION_EVENT_SCREENSHOT:
787-
BugReporting.setInvocationEvents(InstabugInvocationEvent.SCREENSHOT_GESTURE);
794+
parsedInvocationEvents.add(InstabugInvocationEvent.SCREENSHOT_GESTURE);
788795
break;
789796
case INVOCATION_EVENT_NONE:
790-
BugReporting.setInvocationEvents(InstabugInvocationEvent.NONE);
797+
parsedInvocationEvents.add(InstabugInvocationEvent.NONE);
791798
break;
792799
default:
793-
BugReporting.setInvocationEvents(InstabugInvocationEvent.SHAKE);
800+
parsedInvocationEvents.add(InstabugInvocationEvent.SHAKE);
794801
break;
795802
}
796803
}
804+
BugReporting.setInvocationEvents(parsedInvocationEvents.toArray(new InstabugInvocationEvent[0]));
797805
} catch (Exception e) {
798806
e.printStackTrace();
799807
}

0 commit comments

Comments
 (0)