@@ -651,6 +651,7 @@ private byte[] newClientInternal(byte[] identity, String storePath, String bloxA
651651 Log .d ("ReactNative" , "Creating a new Fula instance" );
652652 try {
653653 shutdownInternal ();
654+ Log .d ("ReactNative" , "Creating a new Fula instance with config" );
654655 this .fula = Fulamobile .newClient (fulaConfig );
655656 if (this .fula != null ) {
656657 this .fula .flush ();
@@ -1121,6 +1122,8 @@ private void shutdownInternal() throws Exception {
11211122 this .fula .shutdown ();
11221123 this .fula = null ;
11231124 this .client = null ;
1125+ Log .d ("ReactNative" , "shutdownInternal done" );
1126+
11241127 }
11251128 } catch (Exception e ) {
11261129 Log .d ("ReactNative" , "shutdownInternal" + e .getMessage ());
@@ -1216,11 +1219,12 @@ public void listPools(Promise promise) {
12161219 }
12171220
12181221 @ ReactMethod
1219- public void joinPool (String seedString , long poolID , Promise promise ) {
1222+ public void joinPool (String poolID , Promise promise ) {
12201223 ThreadUtils .runOnExecutor (() -> {
1221- Log .d ("ReactNative" , "joinPool: seedString = " + seedString + "; poolID = " + poolID );
1224+ long poolIdLong = Long .parseLong (poolID );
1225+ Log .d ("ReactNative" , "joinPool: poolID = " + poolIdLong );
12221226 try {
1223- byte [] result = this .fula .poolJoin (seedString , poolID );
1227+ byte [] result = this .fula .poolJoin (poolIdLong );
12241228 String resultString = toString (result );
12251229 promise .resolve (resultString );
12261230 } catch (Exception e ) {
@@ -1231,11 +1235,11 @@ public void joinPool(String seedString, long poolID, Promise promise) {
12311235 }
12321236
12331237 @ ReactMethod
1234- public void cancelPoolJoin (String seedString , long poolID , Promise promise ) {
1238+ public void cancelPoolJoin (long poolID , Promise promise ) {
12351239 ThreadUtils .runOnExecutor (() -> {
1236- Log .d ("ReactNative" , "cancelPoolJoin: seedString = " + seedString + "; poolID = " + poolID );
1240+ Log .d ("ReactNative" , "cancelPoolJoin: poolID = " + poolID );
12371241 try {
1238- byte [] result = this .fula .poolCancelJoin (seedString , poolID );
1242+ byte [] result = this .fula .poolCancelJoin (poolID );
12391243 String resultString = toString (result );
12401244 promise .resolve (resultString );
12411245 } catch (Exception e ) {
@@ -1276,11 +1280,11 @@ public void votePoolJoinRequest(String seedString, long poolID, String accountSt
12761280 }
12771281
12781282 @ ReactMethod
1279- public void leavePool (String seedString , long poolID , Promise promise ) {
1283+ public void leavePool (long poolID , Promise promise ) {
12801284 ThreadUtils .runOnExecutor (() -> {
1281- Log .d ("ReactNative" , "leavePool: seedString = " + seedString + "; poolID = " + poolID );
1285+ Log .d ("ReactNative" , "leavePool: poolID = " + poolID );
12821286 try {
1283- byte [] result = this .fula .poolLeave (seedString , poolID );
1287+ byte [] result = this .fula .poolLeave (poolID );
12841288 String resultString = toString (result );
12851289 promise .resolve (resultString );
12861290 } catch (Exception e ) {
@@ -1380,6 +1384,69 @@ public void removeStoredReplication(String seedString, String uploader, long poo
13801384 });
13811385 }
13821386
1387+ @ ReactMethod
1388+ private void listRecentCidsAsString (Promise promise ) throws Exception {
1389+ ThreadUtils .runOnExecutor (() -> {
1390+ try {
1391+ if (this .fula != null ) {
1392+ Log .d ("ReactNative" , "ListRecentCidsAsString" );
1393+ fulamobile .StringIterator recentLinks = this .fula .listRecentCidsAsString ();
1394+ ArrayList <String > recentLinksList = new ArrayList <>();
1395+ while (recentLinks .hasNext ()) {
1396+ recentLinksList .add (recentLinks .next ());
1397+ }
1398+ if (!recentLinksList .isEmpty ()) {
1399+ // return the whole list
1400+ Log .d ("ReactNative" , "ListRecentCidsAsString found: " + recentLinksList );
1401+ WritableArray recentLinksArray = Arguments .createArray ();
1402+ for (String link : recentLinksList ) {
1403+ recentLinksArray .pushString (link );
1404+ }
1405+ promise .resolve (recentLinksArray );
1406+ } else {
1407+ promise .resolve (false );
1408+ }
1409+ } else {
1410+ throw new Exception ("ListRecentCidsAsString: Fula is not initialized" );
1411+ }
1412+ } catch (Exception e ) {
1413+ Log .d ("ReactNative" , "ListRecentCidsAsString failed with Error: " + e .getMessage ());
1414+ try {
1415+ throw (e );
1416+ } catch (Exception ex ) {
1417+ throw new RuntimeException (ex );
1418+ }
1419+ }
1420+ });
1421+ }
1422+
1423+ @ ReactMethod
1424+ public void clearCidsFromRecent (ReadableArray cidArray , Promise promise ) {
1425+ ThreadUtils .runOnExecutor (() -> {
1426+ try {
1427+ if (this .fula != null ) {
1428+ StringBuilder cidStrBuilder = new StringBuilder ();
1429+ for (int i = 0 ; i < cidArray .size (); i ++) {
1430+ if (i > 0 ) {
1431+ cidStrBuilder .append ("|" );
1432+ }
1433+ cidStrBuilder .append (cidArray .getString (i ));
1434+ }
1435+
1436+ byte [] cidsBytes = cidStrBuilder .toString ().getBytes (StandardCharsets .UTF_8 );
1437+ this .fula .clearCidsFromRecent (cidsBytes );
1438+ promise .resolve (true ); // Indicate success
1439+ } else {
1440+ throw new Exception ("clearCidsFromRecent: Fula is not initialized" );
1441+ }
1442+ } catch (Exception e ) {
1443+ Log .d ("ReactNative" , "clearCidsFromRecent failed with Error: " + e .getMessage ());
1444+ promise .reject ("Error" , e .getMessage ());
1445+ }
1446+ });
1447+ }
1448+
1449+
13831450 ////////////////////////////////////////////////////////////////
13841451 ///////////////// Blox Hardware Methods ////////////////////////
13851452 ////////////////////////////////////////////////////////////////
0 commit comments