Skip to content

Commit

Permalink
Merge pull request #1 from Peach2Peach/origin/new-sync-thread
Browse files Browse the repository at this point in the history
Origin/new sync thread
  • Loading branch information
Czino authored Jun 15, 2023
2 parents 9c99386 + 0047365 commit f0b9e03
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
6 changes: 4 additions & 2 deletions android/src/main/java/io/ltbl/bdkrn/BdkRnModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,10 @@ class BdkRnModule(reactContext: ReactApplicationContext) :
@ReactMethod
fun sync(id: String, blockChainId: String, result: Promise) {
try {
getWalletById(id).sync(getBlockchainById(blockChainId), BdkProgress)
result.resolve(true)
Thread {
getWalletById(id).sync(getBlockchainById(blockChainId), BdkProgress)
result.resolve(true)
}.start()
} catch (error: Throwable) {
result.reject("Sync wallet error", error.localizedMessage, error)
}
Expand Down
12 changes: 7 additions & 5 deletions ios/BdkRnModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -494,11 +494,13 @@ class BdkRnModule: NSObject {
resolve: @escaping RCTPromiseResolveBlock,
reject: @escaping RCTPromiseRejectBlock
) {
do {
try getWalletById(id: id).sync(blockchain: getBlockchainById(id: blockChainId), progress: BdkProgress())
resolve(true)
} catch let error {
reject("Sync wallet error", "\(error)", error)
DispatchQueue.main.async { [self] in
do {
try getWalletById(id: id).sync(blockchain: self.getBlockchainById(id: blockChainId), progress: BdkProgress())
resolve(true)
} catch let error {
reject("Sync wallet error", "\(error)", error)
}
}
}

Expand Down

0 comments on commit f0b9e03

Please sign in to comment.