Skip to content

Commit 84b7114

Browse files
committed
chore: use responseOnMainThread as default for progressOnMainThread if not defined
1 parent e53584a commit 84b7114

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/https/request.android.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ export function createRequest(opts: HttpsRequestOptions, useLegacy: boolean = tr
603603
if (opts.responseOnMainThread === false) {
604604
nResponse.runOnMainThread = false;
605605
}
606-
if (opts.progressOnMainThread === false) {
606+
if (opts.progressOnMainThread === false || (opts.progressOnMainThread === undefined && opts.responseOnMainThread === false)) {
607607
nResponse.runProgressOnMainThread = false;
608608
}
609609
if (opts.onProgress) {

src/https/request.ios.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ function nativeToObj(data, encoding?) {
7171
});
7272
return content;
7373
} else if (data instanceof NSData) {
74-
return NSString.alloc().initWithDataEncoding(data, encoding === 'ascii' ? NSASCIIStringEncoding : NSUTF8StringEncoding).toString();
74+
return NSString.alloc()
75+
.initWithDataEncoding(data, encoding === 'ascii' ? NSASCIIStringEncoding : NSUTF8StringEncoding)
76+
.toString();
7577
} else {
7678
return data;
7779
}
@@ -380,7 +382,7 @@ export function createRequest(opts: HttpsRequestOptions, useLegacy: boolean = tr
380382

381383
const progress = opts.onProgress
382384
? (progress: NSProgress) => {
383-
if (opts.progressOnMainThread === false) {
385+
if (opts.progressOnMainThread === false || (opts.progressOnMainThread === undefined && opts.responseOnMainThread === false)) {
384386
opts.onProgress(progress.completedUnitCount, progress.totalUnitCount);
385387
} else {
386388
Utils.dispatchToMainThread(() => {

0 commit comments

Comments
 (0)