Skip to content

Commit a129cb4

Browse files
committed
fix: add react context getter to LdkEventEmitter
1 parent efc40ef commit a129cb4

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

lib/android/src/main/java/com/reactnativeldk/LdkModule.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1730,6 +1730,10 @@ object LdkEventEmitter {
17301730
this.reactContext = reactContext
17311731
}
17321732

1733+
fun getReactContext(): ReactContext? {
1734+
return this.reactContext
1735+
}
1736+
17331737
fun send(eventType: EventTypes, body: Any) {
17341738
if (this.reactContext === null) {
17351739
return

lib/android/src/main/java/com/reactnativeldk/classes/LdkPersister.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class LdkPersister {
3939
file.writeBytes(serialized)
4040

4141
// Update chain monitor on main thread
42-
LdkModule.reactContext?.runOnUiThread {
42+
LdkModule.getReactContext()?.runOnUiThread {
4343
val res = LdkModule.chainMonitor?.channel_monitor_updated(channelFundingOutpoint, data._latest_update_id)
4444
if (res == null || !res.is_ok) {
4545
LdkEventEmitter.send(EventTypes.native_log, "Failed to update chain monitor with persisted channel (${channelId})")
@@ -75,7 +75,7 @@ class LdkPersister {
7575
}
7676

7777
//Update chain monitor with successful persist on main thread
78-
LdkModule.reactContext?.runOnUiThread {
78+
LdkModule.getReactContext()?.runOnUiThread {
7979
val res = LdkModule.chainMonitor?.channel_monitor_updated(channelFundingOutpoint, data._latest_update_id)
8080
if (res == null || !res.is_ok) {
8181
LdkEventEmitter.send(EventTypes.native_log, "Failed to update chain monitor with persisted channel (${channelId})")

0 commit comments

Comments
 (0)