fix upgrade code

This commit is contained in:
pokkst 2022-10-15 01:08:15 -05:00
parent 90e556abff
commit 95eb106a40
No known key found for this signature in database
GPG key ID: 90C2ED85E67A50FF
2 changed files with 13 additions and 11 deletions

View file

@ -109,7 +109,7 @@ public class MainActivity extends AppCompatActivity implements MoneroHandlerThre
}
private void upgradeOldNodePrefs() {
PrefService.getInstance().getNode();
PrefService.getInstance().upgradeNodePrefs();
}
@Override

View file

@ -26,6 +26,17 @@ public class PrefService extends ServiceBase {
}
public Node getNode() {
boolean usesProxy = getBoolean(Constants.PREF_USES_TOR, false);
DefaultNodes defaultNode = usesProxy ? DefaultNodes.SAMOURAI_ONION : DefaultNodes.SAMOURAI;
String nodeString = getString(Constants.PREF_NODE_2, defaultNode.getUri());
if(!nodeString.isEmpty()) {
return Node.fromString(nodeString);
} else {
return null;
}
}
public void upgradeNodePrefs() {
String oldNodeString = getString("pref_node", "");
if(!oldNodeString.isEmpty()) {
//upgrade old node pref to new node pref
@ -41,14 +52,6 @@ public class PrefService extends ServiceBase {
e.printStackTrace();
}
}
boolean usesProxy = getBoolean(Constants.PREF_USES_TOR, false);
DefaultNodes defaultNode = usesProxy ? DefaultNodes.SAMOURAI_ONION : DefaultNodes.SAMOURAI;
String nodeString = getString(Constants.PREF_NODE_2, defaultNode.getUri());
if(!nodeString.isEmpty()) {
return Node.fromString(nodeString);
} else {
return null;
}
}
private Node getNode(String oldNodeString) throws JSONException {
@ -79,8 +82,7 @@ public class PrefService extends ServiceBase {
if(nodeString.isEmpty()) {
return null;
} else {
Node oldNode = Node.fromString(nodeString);
return oldNode;
return Node.fromString(nodeString);
}
}