Skip to content

Commit 84fc46e

Browse files
committed
added refresh to newClient
1 parent f255441 commit 84fc46e

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,14 +170,14 @@ public void checkConnection(Promise promise) {
170170
}
171171

172172
@ReactMethod
173-
public void newClient(String identityString, String storePath, String bloxAddr, String exchange, boolean autoFlush, boolean useRelay, Promise promise) {
173+
public void newClient(String identityString, String storePath, String bloxAddr, String exchange, boolean autoFlush, boolean useRelay, boolean refresh, Promise promise) {
174174
Log.d("ReactNative", "newClient started");
175175
ThreadUtils.runOnExecutor(() -> {
176176
try {
177177
Log.d("ReactNative", "newClient storePath= " + storePath);
178178
byte[] identity = toByte(identityString);
179179
Log.d("ReactNative", "newClient identity= " + identityString);
180-
this.newClientInternal(identity, storePath, bloxAddr, exchange, autoFlush, useRelay);
180+
this.newClientInternal(identity, storePath, bloxAddr, exchange, autoFlush, useRelay, refresh);
181181
//String objString = Arrays.toString(obj);
182182
String peerId = this.fula.id();
183183
promise.resolve(peerId);
@@ -474,7 +474,7 @@ public fulamobile.Client getFulaClient() {
474474
}
475475

476476
@NonNull
477-
private byte[] newClientInternal(byte[] identity, String storePath, String bloxAddr, String exchange, boolean autoFlush, boolean useRelay) throws Exception {
477+
private byte[] newClientInternal(byte[] identity, String storePath, String bloxAddr, String exchange, boolean autoFlush, boolean useRelay, boolean refresh) throws Exception {
478478
try {
479479
fulaConfig = new Config();
480480
if (storePath == null || storePath.trim().isEmpty()) {
@@ -495,7 +495,7 @@ private byte[] newClientInternal(byte[] identity, String storePath, String bloxA
495495
fulaConfig.setAllowTransientConnection(true);
496496
fulaConfig.setForceReachabilityPrivate(true);
497497
}
498-
if (this.fula == null) {
498+
if (this.fula == null || refresh) {
499499
Log.d("ReactNative", "Creating a new Fula instance");
500500
this.fula = Fulamobile.newClient(fulaConfig);
501501
}
@@ -513,7 +513,7 @@ private byte[] newClientInternal(byte[] identity, String storePath, String bloxA
513513
private String[] initInternal(byte[] identity, String storePath, String bloxAddr, String exchange, boolean autoFlush, String rootCid, boolean useRelay, boolean refresh) throws Exception {
514514
try {
515515
if (this.fula == null || refresh) {
516-
this.newClientInternal(identity, storePath, bloxAddr, exchange, autoFlush, useRelay);
516+
this.newClientInternal(identity, storePath, bloxAddr, exchange, autoFlush, useRelay, refresh);
517517
}
518518
if(this.client == null || refresh) {
519519
this.client = new Client(this.fula);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@functionland/react-native-fula",
3-
"version": "1.1.4",
3+
"version": "1.1.5",
44
"description": "This package is a bridge to use the Fula libp2p protocols in the react-native which is using wnfs",
55
"main": "lib/commonjs/index",
66
"module": "lib/module/index",

src/interfaces/fulaNativeModule.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ interface FulaNativeModule {
1717
bloxAddr: string, //Blox multiadddr needs to be manually entered now
1818
exchange: string, //set to 'noope' for testing
1919
autoFlush: boolean, //set to false always unless you know what you are doing. This is to write actions to disk explicitly after each write
20-
useRelay: boolean | null // if true it forces the use of relay
20+
useRelay: boolean | null, // if true it forces the use of relay
21+
refresh: boolean // if true it forces to refresh the fula object
2122
) => Promise<string>;
2223
isReady: (filesystemCheck: boolean) => Promise<boolean>;
2324
logout: (identity: string, storePath: string) => Promise<boolean>;

src/protocols/fula.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ export const newClient = (
4242
bloxAddr: string,
4343
exchange: string,
4444
autoFlush: boolean = false,
45-
useRelay: boolean = true
45+
useRelay: boolean = true,
46+
refresh: boolean = false
4647
): Promise<string> => {
4748
console.log(
4849
'newClient in react-native started',
@@ -51,9 +52,10 @@ export const newClient = (
5152
bloxAddr,
5253
exchange,
5354
autoFlush,
54-
useRelay
55+
useRelay,
56+
refresh
5557
);
56-
return Fula.newClient(identity, storePath, bloxAddr, exchange, autoFlush, useRelay);
58+
return Fula.newClient(identity, storePath, bloxAddr, exchange, autoFlush, useRelay, refresh);
5759
};
5860

5961
/**

0 commit comments

Comments
 (0)