fix: empty endpoint text if node not connected

This commit is contained in:
poka 2022-05-27 11:22:43 +02:00
parent 05b425c3d2
commit 8c390e511e
5 changed files with 8 additions and 10 deletions

View File

@ -84,6 +84,7 @@ Future<void> main() async {
endPointGVA = 'https://g1.librelois.fr/gva'; endPointGVA = 'https://g1.librelois.fr/gva';
// endPointGVA = 'https://duniter-g1.p2p.legal/gva'; // endPointGVA = 'https://duniter-g1.p2p.legal/gva';
await _homeProvider.getValidEndpoints(); await _homeProvider.getValidEndpoints();
// log.d(await configBox.get('endpoint'));
// if (endPointGVA == 'HS') { // if (endPointGVA == 'HS') {
// _homeProvider.playSound('faché', 0.8); // _homeProvider.playSound('faché', 0.8);

View File

@ -61,7 +61,9 @@ class HomeProvider with ChangeNotifier {
configBox.delete('endpoint'); configBox.delete('endpoint');
List _listEndpoints = []; List _listEndpoints = [];
if (!configBox.containsKey('endpoint') || configBox.get('endpoint') == []) { if (!configBox.containsKey('endpoint') ||
configBox.get('endpoint') == [] ||
configBox.get('endpoint') == '') {
_listEndpoints = await rootBundle _listEndpoints = await rootBundle
.loadString('config/gdev_endpoints.json') .loadString('config/gdev_endpoints.json')
.then((jsonStr) => jsonDecode(jsonStr)); .then((jsonStr) => jsonDecode(jsonStr));
@ -69,6 +71,8 @@ class HomeProvider with ChangeNotifier {
configBox.put('endpoint', _listEndpoints); configBox.put('endpoint', _listEndpoints);
} }
log.i('ENDPOINT: ' + _listEndpoints.toString());
// int i = 0; // int i = 0;
// String? _endpoint; // String? _endpoint;
// int _statusCode = 0; // int _statusCode = 0;
@ -111,7 +115,6 @@ class HomeProvider with ChangeNotifier {
// } // }
// } while (_statusCode != 400); // } while (_statusCode != 400);
log.i('ENDPOINT: ' + _listEndpoints.toString());
return _listEndpoints; return _listEndpoints;
} }

View File

@ -21,12 +21,6 @@ class MyWalletsProvider with ChangeNotifier {
} }
bool checkIfWalletExist() { bool checkIfWalletExist() {
// configBox.delete('endpoint');
// if (!configBox.containsKey('endpoint') || configBox.get('endpoint') == []) {
// log.d('No endpoint, configure...');
// configBox.put('endpoint', 'wss://gdev.librelois.fr/ws');
// }
if (chestBox.isEmpty) { if (chestBox.isEmpty) {
log.i('No wallets detected'); log.i('No wallets detected');
return false; return false;

View File

@ -48,6 +48,7 @@ class SubstrateSdk with ChangeNotifier {
List<NetworkParams> node = []; List<NetworkParams> node = [];
for (String _endpoint in configBox.get('endpoint')) { for (String _endpoint in configBox.get('endpoint')) {
log.d(_endpoint);
final n = NetworkParams(); final n = NetworkParams();
n.name = currencyName; n.name = currencyName;
n.endpoint = _endpoint; n.endpoint = _endpoint;

View File

@ -30,13 +30,12 @@ class SettingsScreen extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
SubstrateSdk _sub = Provider.of<SubstrateSdk>(context, listen: false);
const double buttonHigh = 50; const double buttonHigh = 50;
const double buttonWidth = 240; const double buttonWidth = 240;
const double fontSize = 16; const double fontSize = 16;
TextEditingController _endpointController = TextEditingController _endpointController =
TextEditingController(text: _sub.getConnectedEndpoint()); TextEditingController(text: configBox.get('endpoint').first);
// getAppDirectory(); // getAppDirectory();
return Scaffold( return Scaffold(