upgrade old node prefs if valid node

This commit is contained in:
pokkst 2022-10-15 00:00:54 -05:00
parent c1b4f8400d
commit 6d0ddad674
No known key found for this signature in database
GPG Key ID: 90C2ED85E67A50FF

View File

@ -13,6 +13,7 @@ import androidx.fragment.app.FragmentManager;
import androidx.navigation.fragment.NavHostFragment;
import net.mynero.wallet.data.DefaultNodes;
import net.mynero.wallet.data.Node;
import net.mynero.wallet.fragment.dialog.PasswordBottomSheetDialog;
import net.mynero.wallet.fragment.dialog.SendBottomSheetDialog;
import net.mynero.wallet.livedata.SingleLiveEvent;
@ -92,6 +93,7 @@ public class MainActivity extends AppCompatActivity implements MoneroHandlerThre
}
public void init(File walletFile, String password) {
upgradeOldNodePrefs();
Wallet wallet = WalletManager.getInstance().openWallet(walletFile.getAbsolutePath(), password);
thread = new MoneroHandlerThread("WalletService", this, wallet);
new TxService(thread);
@ -103,6 +105,16 @@ public class MainActivity extends AppCompatActivity implements MoneroHandlerThre
thread.start();
}
private void upgradeOldNodePrefs() {
String oldNodeString = PrefService.getInstance().getString("pref_node", "");
if(!oldNodeString.isEmpty()) {
Node oldNode = Node.fromString(oldNodeString);
if(oldNode != null) {
PrefService.getInstance().edit().putString(Constants.PREF_NODE_2, oldNode.toNodeString()).apply();
}
}
}
@Override
public void onRefresh() {
this.historyService.refreshHistory();