Skip to content

Commit a9882a9

Browse files
committed
fixup: fix requestMultiple
1 parent 7ea8d0c commit a9882a9

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/module.windows.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {NativeModules} from 'react-native';
2-
import {RESULTS, PERMISSIONS} from './constants';
32
import {Contract} from './contract';
43
import {NotificationsResponse, Permission, PermissionStatus} from './types';
54
import {uniq} from './utils';
@@ -38,7 +37,8 @@ async function checkMultiple<P extends Permission[]>(
3837
permissions: P,
3938
): Promise<Record<P[number], PermissionStatus>> {
4039
const result = {} as Record<P[number], PermissionStatus>;
41-
const promises = permissions.map(async (permission: P[number]) => {
40+
const dedup = uniq(permissions);
41+
const promises = dedup.map(async (permission: P[number]) => {
4242
const promise = check(permission);
4343
result[permission] = await promise;
4444
return promise;
@@ -51,12 +51,11 @@ async function requestMultiple<P extends Permission[]>(
5151
permissions: P,
5252
): Promise<Record<P[number], PermissionStatus>> {
5353
const result = {} as Record<P[number], PermissionStatus>;
54-
const promises = permissions.map(async (permission: P[number]) => {
55-
const promise = request(permission);
56-
result[permission] = await promise;
57-
return promise;
58-
});
59-
Promise.all(promises);
54+
const dedup = uniq(permissions);
55+
for (let idx = 0; idx < dedup.length; ++idx) {
56+
const permission: P[number] = dedup[idx];
57+
result[permission] = await request(permission);
58+
}
6059
return result;
6160
}
6261

0 commit comments

Comments
 (0)