diff --git a/android/src/main/java/land/fx/fula/FulaModule.java b/android/src/main/java/land/fx/fula/FulaModule.java index 3401564..fb1fab2 100755 --- a/android/src/main/java/land/fx/fula/FulaModule.java +++ b/android/src/main/java/land/fx/fula/FulaModule.java @@ -187,6 +187,23 @@ public void newClient(String identityString, String storePath, String bloxAddr, }); } + @ReactMethod + public void isReady(Promise promise) { + Log.d("ReactNative", "isReady started"); + ThreadUtils.runOnExecutor(() -> { + boolean initialized = false; + try { + if (this.fula != null && this.fula.id() != null) { + initialized = true; + } + promise.resolve(initialized); + } catch (Exception e) { + Log.d("ReactNative", "isReady failed with Error: " + e.getMessage()); + promise.reject("Error", e.getMessage()); + } + }); + } + @ReactMethod public void init(String identityString, String storePath, String bloxAddr, String exchange, boolean autoFlush, String rootConfig, Promise promise) { Log.d("ReactNative", "init started"); diff --git a/package.json b/package.json index 4fd6538..304bd55 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@functionland/react-native-fula", - "version": "1.0.6", + "version": "1.0.7", "description": "This package is a bridge to use the Fula libp2p protocols in the react-native which is using wnfs", "main": "lib/commonjs/index", "module": "lib/module/index", diff --git a/src/interfaces/fulaNativeModule.ts b/src/interfaces/fulaNativeModule.ts index 7916a4d..68cc5f1 100644 --- a/src/interfaces/fulaNativeModule.ts +++ b/src/interfaces/fulaNativeModule.ts @@ -16,6 +16,7 @@ interface FulaNativeModule { exchange: string, //set to 'noope' for testing autoFlush: boolean //set to false always unless you know what you are doing. This is to write actions to disk explicitly after each write ) => Promise; + isReady: () => Promise; logout: (identity: string, storePath: string) => Promise; checkFailedActions: (retry: boolean) => Promise; checkConnection: () => Promise; diff --git a/src/protocols/fula.ts b/src/protocols/fula.ts index 40b5742..bd6adb8 100644 --- a/src/protocols/fula.ts +++ b/src/protocols/fula.ts @@ -253,3 +253,12 @@ export const readFileContent = (path: string): Promise => { export const shutdown = (): Promise => { return Fula.shutdown(); }; + +/** + * rm removes all files and folders at a given path + * @param path + * @returns string: new cid of the root + */ +export const isReady = (): Promise => { + return Fula.isReady(); +};