Skip to content

Commit 6a42e4f

Browse files
authored
Merge pull request #49 from functionland/WNFS-check-isReady
Added WNFS check to isReady
2 parents 4795733 + 80b587c commit 6a42e4f

File tree

5 files changed

+17
-8
lines changed

5 files changed

+17
-8
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,9 @@ await fula.mv(
119119
//checks if fula is ready (initialized through newClient or init)
120120
const result //returns true if succesful and false if fails
121121
=
122-
await fula.isReady();
122+
await fula.isReady(
123+
filesystemCheck: boolean //Default is true. If true it checks if both WNFS and Fula are ready. If false it only checks fula
124+
);
123125

124126
```
125127

android/src/main/java/land/fx/fula/FulaModule.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,13 +188,19 @@ public void newClient(String identityString, String storePath, String bloxAddr,
188188
}
189189

190190
@ReactMethod
191-
public void isReady(Promise promise) {
191+
public void isReady(boolean filesystemCheck, Promise promise) {
192192
Log.d("ReactNative", "isReady started");
193193
ThreadUtils.runOnExecutor(() -> {
194194
boolean initialized = false;
195195
try {
196196
if (this.fula != null && this.fula.id() != null) {
197-
initialized = true;
197+
if (filesystemCheck) {
198+
if (this.client != null && this.rootConfig != null && !this.rootConfig.getCid().isEmpty()) {
199+
initialized = true;
200+
}
201+
} else {
202+
initialized = true;
203+
}
198204
}
199205
promise.resolve(initialized);
200206
} catch (Exception e) {

example/src/App.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,13 @@ const App = () => {
3737
94, 225, 7, 153, 168, 239, 94, 7, 187, 123, 158, 149, 149, 227, 170, 32, 54,
3838
203, 243, 211, 78, 120, 114, 199, 1, 197, 134, 6, 91, 87, 152,
3939
];
40+
const bloxAddr = '/dns/relay.dev.fx.land/tcp/4001/p2p/12D3KooWDRrBaAfPwsGJivBoUw5fE7ZpDiyfUjqgiURq2DEcL835/p2p-circuit/p2p/12D3KooWR2EiA8DbULqDAJZCcN2V2Nasmh756R1aLe5t3NniCnAS';
4041
const newClient = async () => {
4142
try {
4243
return fula.newClient(
4344
privateKey.toString(),
4445
'',
45-
'/ip4/192.168.2.14/tcp/40001/p2p/12D3KooWBdzmgXe9uyYoxaeLLKTLWM7mG3ZtBiKHAnSVxtrVJc2A',
46+
bloxAddr,
4647
''
4748
);
4849
} catch (e) {
@@ -55,7 +56,7 @@ const App = () => {
5556
return fula.init(
5657
privateKey.toString(),
5758
'',
58-
'/ip4/192.168.2.14/tcp/40001/p2p/12D3KooWBdzmgXe9uyYoxaeLLKTLWM7mG3ZtBiKHAnSVxtrVJc2A',
59+
bloxAddr,
5960
''
6061
);
6162
} catch (e) {

src/interfaces/fulaNativeModule.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ interface FulaNativeModule {
1616
exchange: string, //set to 'noope' for testing
1717
autoFlush: boolean //set to false always unless you know what you are doing. This is to write actions to disk explicitly after each write
1818
) => Promise<string>;
19-
isReady: () => Promise<boolean>;
19+
isReady: (filesystemCheck: boolean) => Promise<boolean>;
2020
logout: (identity: string, storePath: string) => Promise<boolean>;
2121
checkFailedActions: (retry: boolean) => Promise<boolean>;
2222
checkConnection: () => Promise<boolean>;

src/protocols/fula.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,6 @@ export const shutdown = (): Promise<void> => {
259259
* @param path
260260
* @returns string: new cid of the root
261261
*/
262-
export const isReady = (): Promise<boolean> => {
263-
return Fula.isReady();
262+
export const isReady = (filesystemCheck: boolean = true): Promise<boolean> => {
263+
return Fula.isReady(filesystemCheck);
264264
};

0 commit comments

Comments
 (0)