Skip to content

Commit

Permalink
Add native implementation for IntendedPanic
Browse files Browse the repository at this point in the history
  • Loading branch information
ilmotta committed Dec 2, 2024
1 parent 5d55b9a commit 25a41f0
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,15 @@ class StatusModule(private val reactContext: ReactApplicationContext, private va
)
}

@ReactMethod
fun intendedPanic(message: String) {
StatusBackendClient.executeStatusGoRequest(
endpoint = "IntendedPanic",
requestBody = "",
statusgoFunction = { Statusgo.intendedPanic(message) },
)
}

@ReactMethod
fun addCentralizedMetric(request: String, callback: Callback) {
StatusBackendClient.executeStatusGoRequestWithCallback(
Expand Down
7 changes: 7 additions & 0 deletions modules/react-native-status/ios/RCTStatus/RCTStatus.m
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,13 @@ - (void)handleSignal:(NSString *)signal
callback:callback];
}

RCT_EXPORT_METHOD(intendedPanic:(NSString *)message) {
#if DEBUG
NSLog(@"IntendedPanic() method called");
#endif
StatusgoIntendedPanic(message);
}

RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(fleets) {
return [StatusBackendClient executeStatusGoRequestWithResult:@"Fleets"
body:@""
Expand Down
4 changes: 4 additions & 0 deletions src/native_module/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -581,3 +581,7 @@
(.createAccountFromPrivateKey ^js (account-manager)
(types/clj->json {:privateKey private-key})
callback)))

(defn intended-panic
[message]
(.intendedPanic ^js (status) message))
15 changes: 6 additions & 9 deletions src/tests/test_utils.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,9 @@

(def status
(clj->js
{:getNodeConfig
(fn [] (types/clj->json {:WakuV2Config ""}))
:addCentralizedMetric
(fn [_ callback]
(callback))
:fleets
(fn [] (.fleets native-status))
:startLocalNotifications
identity}))
{:intendedPanic identity
:getNodeConfig (fn [] (types/clj->json {:WakuV2Config ""}))
:addCentralizedMetric (fn [_ callback]
(callback))
:fleets (fn [] (.fleets native-status))
:startLocalNotifications identity}))

0 comments on commit 25a41f0

Please sign in to comment.