Skip to content

Commit 5fa9874

Browse files
committed
fix: resolve comments
1 parent 2e2ace8 commit 5fa9874

File tree

5 files changed

+53
-19
lines changed

5 files changed

+53
-19
lines changed

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,33 @@ public void run() {
389389
}
390390
});
391391
}
392+
/**
393+
* Sets a minimum number of characters as a requirement for the comments field in the different report types.
394+
* @param limit int number of characters.
395+
* @param reportTypes (Optional) Array of reportType. If it's not passed, the limit will apply to all report types.
396+
*/
397+
@ReactMethod
398+
public void setCommentMinimumCharacterCount(final int limit, final ReadableArray reportTypes){
399+
MainThreadHandler.runOnMainThread(new Runnable() {
400+
@SuppressLint("WrongConstant")
401+
@Override
402+
public void run() {
403+
try {
404+
final ArrayList<String> keys = ArrayUtil.parseReadableArrayOfStrings(reportTypes);
405+
final ArrayList<Integer> types = ArgsRegistry.reportTypes.getAll(keys);
406+
407+
final int[] typesInts = new int[types.size()];
408+
for (int i = 0; i < types.size(); i++) {
409+
typesInts[i] = types.get(i);
410+
}
411+
412+
BugReporting.setCommentMinimumCharacterCount(limit, typesInts);
413+
} catch (Exception e) {
414+
e.printStackTrace();
415+
}
416+
}
417+
});
418+
}
392419

393420
/**
394421
* Adds a user consent item to the bug reporting

android/src/test/java/com/instabug/reactlibrary/RNInstabugBugReportingModuleTest.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,24 @@ public Object answer(InvocationOnMock invocation) {
344344
BugReporting.setDisclaimerText(text);
345345
}
346346

347-
347+
@Test
348+
public void givenArgs$setCommentMinimumCharacterCount_whenQuery_thenShouldCallNativeApiWithArgs() {
349+
// given
350+
final int count = 20;
351+
final Map<String, Integer> args = ArgsRegistry.reportTypes;
352+
final String[] keysArray = args.keySet().toArray(new String[0]);
353+
JavaOnlyArray actualArray = new JavaOnlyArray();
354+
actualArray.pushString(keysArray[0]);
355+
356+
// when
357+
bugReportingModule.setCommentMinimumCharacterCount(count, actualArray);
358+
359+
// then
360+
verify(BugReporting.class, VerificationModeFactory.times(1));
361+
int type1 = args.get(keysArray[0]);
362+
363+
BugReporting.setCommentMinimumCharacterCount(count, type1);
364+
}
348365
@Test
349366
public void TestAddUserConsent() {
350367
final Map<String, String> args = ArgsRegistry.userConsentActionType;

ios/RNInstabug/InstabugBugReportingBridge.m

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -205,18 +205,16 @@ - (void) showBugReportingWithReportTypeAndOptionsHelper:(NSArray*)args {
205205
}
206206

207207
RCT_EXPORT_METHOD(setCommentMinimumCharacterCount:(nonnull NSNumber *)limit reportTypes:(NSArray *)reportTypes) {
208-
IBGBugReportingReportType parsedReportTypes = 0;
209-
208+
IBGBugReportingType parsedReportTypes = 0;
210209
if (![reportTypes count]) {
211-
parsedReportTypes = @(IBGBugReportingReportTypeBug).integerValue | @(IBGBugReportingReportTypeFeedback).integerValue | @(IBGBugReportingReportTypeQuestion).integerValue;
210+
parsedReportTypes = @(IBGBugReportingTypeBug).integerValue | @(IBGBugReportingTypeFeedback).integerValue | @(IBGBugReportingTypeQuestion).integerValue;
212211
}
213212
else {
214213
for (NSNumber *reportType in reportTypes) {
215214
parsedReportTypes |= [reportType intValue];
216215
}
217216
}
218-
219-
[IBGBugReporting setCommentMinimumCharacterCount:limit.intValue forBugReportType:parsedReportTypes];
217+
[IBGBugReporting setCommentMinimumCharacterCount:[limit integerValue] forBugReportType:parsedReportTypes];
220218
}
221219

222220
RCT_EXPORT_METHOD(addUserConsent:(NSString *)key

ios/RNInstabug/InstabugReactBridge.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ - (dispatch_queue_t)methodQueue {
6262

6363
RCT_EXPORT_METHOD(setReproStepsConfig:(IBGUserStepsMode)bugMode :(IBGUserStepsMode)crashMode:(IBGUserStepsMode)sessionReplayMode) {
6464
[Instabug setReproStepsFor:IBGIssueTypeBug withMode:bugMode];
65-
[Instabug setReproStepsFor:IBGIssueTypeCrash withMode:crashMode];
66-
[Instabug setReproStepsFor:IBGIssueTypeSessionReplay withMode:sessionReplayMode];
65+
[Instabug setReproStepsFor:IBGIssueTypeAllCrashes withMode:crashMode];
66+
[Instabug setReproStepsFor:IBGIssueTypeSessionReplay withMode:sessionReplayMode];
6767
}
6868

6969
RCT_EXPORT_METHOD(setFileAttachment:(NSString *)fileLocation) {
@@ -170,7 +170,7 @@ - (dispatch_queue_t)methodQueue {
170170
}
171171

172172
RCT_EXPORT_METHOD(setPrimaryColor:(UIColor *)color) {
173-
Instabug.theme.primaryColor = color;
173+
Instabug.tintColor = color;
174174
}
175175

176176
RCT_EXPORT_METHOD(setTheme:(NSDictionary *)themeConfig) {

src/modules/Instabug.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
import {
2-
AppState,
3-
type AppStateStatus,
4-
findNodeHandle,
5-
Platform,
6-
processColor,
7-
} from 'react-native';
1+
import { AppState, type AppStateStatus, findNodeHandle, Platform } from 'react-native';
82

93
import type {
104
NavigationContainerRefWithCurrent,
@@ -393,9 +387,7 @@ export const setColorTheme = (sdkTheme: ColorTheme) => {
393387
* @platform iOS
394388
*/
395389
export const setPrimaryColor = (color: string) => {
396-
if (Platform.OS === 'ios') {
397-
NativeInstabug.setPrimaryColor(processColor(color));
398-
}
390+
NativeInstabug.setTheme({ primaryColor: color });
399391
};
400392

401393
/**

0 commit comments

Comments
 (0)