@@ -5,20 +5,20 @@ import androidx.annotation.NonNull
5
5
import com.facebook.react.bridge.*
6
6
7
7
internal class FastOpenpgpModule (reactContext : ReactApplicationContext ) :
8
- ReactContextBaseJavaModule (reactContext) {
8
+ ReactContextBaseJavaModule (reactContext) {
9
9
10
10
val TAG = " [FastOpenPGPModule]"
11
11
12
- external fun initialize (jsiPtr : Long );
13
- external fun destruct ();
14
- external fun callJSI (jsiPtr : Long , name : String , payload : ByteArray ): ByteArray ;
15
- external fun callNative (name : String , payload : ByteArray ): ByteArray ;
12
+ external fun initialize (jsiPtr : Long );
13
+ external fun destruct ();
14
+ external fun callJSI (jsiPtr : Long , name : String , payload : ByteArray ): ByteArray ;
15
+ external fun callNative (name : String , payload : ByteArray ): ByteArray ;
16
16
17
- companion object {
18
- init {
19
- System .loadLibrary(" fast-openpgp" )
20
- }
17
+ companion object {
18
+ init {
19
+ System .loadLibrary(" fast-openpgp" )
21
20
}
21
+ }
22
22
23
23
@ReactMethod
24
24
fun callJSI (name : String , payload : ReadableArray , promise : Promise ) {
@@ -61,26 +61,22 @@ internal class FastOpenpgpModule(reactContext: ReactApplicationContext) :
61
61
}.start()
62
62
}
63
63
64
- @ReactMethod
65
- fun install (promise : Promise ) {
66
- Thread {
67
- reactApplicationContext.runOnJSQueueThread {
68
- Log .d(TAG , " installing" )
69
- try {
70
- val contextHolder = this .reactApplicationContext.javaScriptContextHolder!! .get()
71
- if (contextHolder.toInt() == 0 ) {
72
- promise.resolve(false )
73
- return @runOnJSQueueThread
74
- }
75
- initialize(contextHolder)
76
- Log .i(TAG , " successfully installed" )
77
- promise.resolve(true )
78
- } catch (exception: java.lang.Exception ) {
79
- Log .e(TAG , " failed to install JSI" , exception)
80
- promise.reject(exception)
81
- }
64
+ @ReactMethod(isBlockingSynchronousMethod = true )
65
+ fun install (): Boolean {
66
+ Log .d(TAG , " installing" )
67
+ try {
68
+ val contextHolder = this .reactApplicationContext.javaScriptContextHolder!! .get()
69
+ if (contextHolder.toInt() == 0 ) {
70
+ Log .d(TAG , " context not available" )
71
+ return false
82
72
}
83
- }.start()
73
+ initialize(contextHolder)
74
+ Log .i(TAG , " successfully installed" )
75
+ return true
76
+ } catch (exception: java.lang.Exception ) {
77
+ Log .e(TAG , " failed to install JSI" , exception)
78
+ return false
79
+ }
84
80
}
85
81
86
82
override fun getName (): String {
@@ -91,4 +87,3 @@ internal class FastOpenpgpModule(reactContext: ReactApplicationContext) :
91
87
destruct();
92
88
}
93
89
}
94
-
0 commit comments