File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,14 @@ import type {
11
11
} from './types' ;
12
12
import { uniq } from './utils' ;
13
13
14
- const available = NativeModule . getConstants ( ) . available ;
14
+ let available : string [ ] | undefined = undefined ;
15
+
16
+ function getAvailable ( ) {
17
+ if ( available === undefined ) {
18
+ available = NativeModule . getConstants ( ) . available ;
19
+ }
20
+ return available ;
21
+ }
15
22
16
23
async function openLimitedPhotoLibraryPicker ( ) : Promise < void > {
17
24
await NativeModule . openLimitedPhotoLibraryPicker ( ) ;
@@ -22,13 +29,13 @@ async function openSettings(): Promise<void> {
22
29
}
23
30
24
31
async function check ( permission : Permission ) : Promise < PermissionStatus > {
25
- return available ?. includes ( permission )
32
+ return getAvailable ( ) ?. includes ( permission )
26
33
? ( NativeModule . check ( permission ) as Promise < PermissionStatus > )
27
34
: RESULTS . UNAVAILABLE ;
28
35
}
29
36
30
37
async function request ( permission : Permission ) : Promise < PermissionStatus > {
31
- return available ?. includes ( permission )
38
+ return getAvailable ( ) ?. includes ( permission )
32
39
? ( NativeModule . request ( permission ) as Promise < PermissionStatus > )
33
40
: RESULTS . UNAVAILABLE ;
34
41
}
You can’t perform that action at this time.
0 commit comments