Translations and fixes

- couple missing strings
- showing error conditioned on kDebug
- debugging network errors
This commit is contained in:
atlasan 2023-02-02 15:45:01 +01:00
parent 1a3df7d2f8
commit 9496b9206b
12 changed files with 84 additions and 52 deletions

View File

@ -104,6 +104,7 @@
"identityConfirmed": "Identity confirmed",
"identityExpired": "Identity expired",
"confirmYourIdentity": "Confirm your identity",
"noResult": "No results",
"noDuniterNodeAvailableTryLater": "No Duniter node available, please try again later",
"youAreConnectedToNode": "You are connected to node",
"accountActivity": "Account activity",
@ -210,5 +211,6 @@
"displaySettings": "Display Settings",
"indexer": "Indexer",
"anAutoNodeChoosed": "A secure and valid node will be automatically used from a random list.",
"rootWallet": "Root Wallet"
"rootWallet": "Root Wallet",
"blockN": "block N°{}"
}

View File

@ -105,6 +105,7 @@
"identityConfirmed": "Identidad confirmada",
"identityExpired": "Identidad caducada",
"confirmYourIdentity": "Confirma tu identidad",
"noResult": "Ningún resultado",
"noDuniterNodeAvailableTryLater": "No hay ningún nodo Duniter disponible, por favor, inténtalo más tarde",
"youAreConnectedToNode": "Estás conectado al nodo",
"accountActivity": "Actividad de la cuenta",
@ -211,5 +212,6 @@
"displaySettings": "Parametros interficie",
"indexer": "Indexer",
"anAutoNodeChoosed": "Se usará automáticamente un nodo seguro y valido desde una lista aleatoria.",
"rootWallet": "Monedero raíz"
"rootWallet": "Monedero raíz",
"blockN": "bloque N°{}"
}

View File

@ -211,5 +211,6 @@
"displaySettings": "Affichage",
"indexer": "Indexer",
"anAutoNodeChoosed": "Un noeud sûr et valide sera choisi automatiquement parmis une liste aléatoire.",
"rootWallet": "Portefeuille racine"
"rootWallet": "Portefeuille racine",
"blockN": "bloc N°{}"
}

View File

@ -105,6 +105,7 @@
"identityConfirmed": "Identitá confermata",
"identityExpired": "Identitá scaduta",
"confirmYourIdentity": "Conferma identitá",
"noResult": "Nessun risultato",
"noDuniterNodeAvailableTryLater": "Non ci sono nodi Duniter disponibili, per favore, riprova piú tardi",
"youAreConnectedToNode": "Sei connesso al nodo",
"accountActivity": "Attivitá del conto",
@ -211,5 +212,6 @@
"displaySettings": "Impostazioni interfaccia",
"indexer": "Indexer",
"anAutoNodeChoosed": "Un nodo sicuro e valido sará automaticamente scelto da una lista casuale.",
"rootWallet": "Portafoglio radice"
"rootWallet": "Portafoglio radice",
"blockN": "blocco N°{}"
}

View File

@ -54,6 +54,7 @@ late int udValue;
// Indexer
late DateTime startBlockchainTime;
bool startBlockchainInitialized = false;
late int currentUdIndex;

View File

@ -31,7 +31,7 @@ class DuniterIndexer with ChangeNotifier {
final request = await client.postUrl(Uri.parse('$endpoint/v1/graphql'));
final response = await request.close();
if (response.statusCode != 200) {
log.d('INDEXER IS OFFILINE');
log.d('INDEXER IS OFFLINE');
indexerEndpoint = '';
isLoadingIndexer = false;
notifyListeners();
@ -47,7 +47,7 @@ class DuniterIndexer with ChangeNotifier {
return true;
}
} catch (e) {
log.d('INDEXER IS OFFILINE');
log.d('INDEXER IS OFFLINE');
indexerEndpoint = '';
isLoadingIndexer = false;
notifyListeners();
@ -227,8 +227,12 @@ Future<bool> isIdtyExist(String name) async {
Future<DateTime> getBlockStart() async {
final result = await _execQuery(getBlockchainStartQ, {});
startBlockchainTime = DateTime.parse(result.data!['block'][0]['created_at']);
return startBlockchainTime;
if(!result.hasException){
startBlockchainTime = DateTime.parse(result.data!['block'][0]['created_at']);
startBlockchainInitialized = true;
return startBlockchainTime;
}
return DateTime(0,0,0,0,0);
}
Future<QueryResult> _execQuery(
@ -311,7 +315,7 @@ Map computeHistoryView(repository, lastDateDelimiter, isDouble) {
finalAmount = '$amount $currencyName';
}
if (date.compareTo(startBlockchainTime) < 0) {
if (startBlockchainInitialized && date.compareTo(startBlockchainTime) < 0) {
isMigrationTime = true;
} else {
isMigrationTime = false;

View File

@ -88,7 +88,12 @@ class SubstrateSdk with ChangeNotifier {
}
Future _getStorage(String call) async {
return await sdk.webView!.evalJavascript('api.query.$call');
try{
return await sdk.webView!.evalJavascript('api.query.$call');
}catch(e){
log.i("catched _getStorage error");
return Future(() {});
}
}
Future _getStorageConst(String call) async {
@ -134,11 +139,14 @@ class SubstrateSdk with ChangeNotifier {
if (certsCounterCache[address] == null) {
certsCounterCache.putIfAbsent(address, () => []);
}
certsCounterCache.update(
address,
(value) =>
[certsReceiver['receivedCount'], certsReceiver['issuedCount']]);
try{
certsCounterCache.update(
address,
(value) =>
[certsReceiver['receivedCount'] as int, certsReceiver['issuedCount'] as int]);
}catch(e){
// catching String to int error .. network error?
}
return certsCounterCache[address]!;
}
@ -370,21 +378,24 @@ class SubstrateSdk with ChangeNotifier {
// }
Future initCurrencyParameters() async {
currencyParameters['ss58'] =
await _getStorageConst('system.ss58Prefix.words');
currencyParameters['minCertForMembership'] =
await _getStorageConst('wot.minCertForMembership.words');
currencyParameters['newAccountPrice'] =
await _getStorageConst('account.newAccountPrice.words');
currencyParameters['existentialDeposit'] =
await _getStorageConst('balances.existentialDeposit.words');
currencyParameters['certPeriod'] =
await _getStorageConst('cert.certPeriod.words');
currencyParameters['certMaxByIssuer'] =
await _getStorageConst('cert.maxByIssuer.words');
currencyParameters['certValidityPeriod'] =
await _getStorageConst('cert.validityPeriod.words');
try{
currencyParameters['ss58'] =
await _getStorageConst('system.ss58Prefix.words');
currencyParameters['minCertForMembership'] =
await _getStorageConst('wot.minCertForMembership.words');
currencyParameters['newAccountPrice'] =
await _getStorageConst('account.newAccountPrice.words');
currencyParameters['existentialDeposit'] =
await _getStorageConst('balances.existentialDeposit.words');
currencyParameters['certPeriod'] =
await _getStorageConst('cert.certPeriod.words');
currencyParameters['certMaxByIssuer'] =
await _getStorageConst('cert.maxByIssuer.words');
currencyParameters['certValidityPeriod'] =
await _getStorageConst('cert.validityPeriod.words');
}catch(e){
log.i('error while getting storageVals (network?)');
}
log.i('currencyParameters: $currencyParameters');
}

View File

@ -116,11 +116,11 @@ class _HomeScreenState extends State<HomeScreen> {
await sub.connectNode(context);
// Currency parameters
await sub.initCurrencyParameters();
// Indexer Blockchain start
getBlockStart();
}
}
// Indexer Blockchain start
getBlockStart();
});
// await sub.connectNode(ctx);
}

View File

@ -17,6 +17,7 @@ import 'package:gecko/screens/myWallets/import_g1_v1.dart';
import 'package:gecko/screens/myWallets/unlocking_wallet.dart';
import 'package:gecko/screens/myWallets/wallet_options.dart';
import 'package:gecko/screens/wallet_view.dart';
import 'package:gecko/screens/myWallets/choose_chest.dart';
import 'package:gecko/widgets/balance.dart';
import 'package:gecko/widgets/bottom_app_bar.dart';
import 'package:gecko/widgets/commons/offline_info.dart';
@ -222,23 +223,23 @@ class _WalletsHomeState extends State<WalletsHome> {
const SizedBox(height: 20),
InkWell(
key: keyChangeChest,
onTap: null,
// () {
// Navigator.push(
// context,
// MaterialPageRoute(builder: (context) {
// return const ChooseChest();
// }),
// );
// },
onTap:
() {
Navigator.push(
context,
MaterialPageRoute(builder: (context) {
return const ChooseChest();
}),
);
},
child: SizedBox(
width: 400,
height: 60,
child: Center(
child: Text('changeChest'.tr(),
style: TextStyle(
style: const TextStyle(
fontSize: 22,
color: Colors.grey[500],
color: orangeC,
fontWeight: FontWeight.w500))),
),
),

View File

@ -249,7 +249,7 @@ class SettingsScreen extends StatelessWidget {
height: sub.getConnectedEndpoint() == null ? 60 : 20,
child: Text(
sub.getConnectedEndpoint() ??
"Un noeud sûr et valide sera choisi automatiquement parmis une liste aléatoire.",
"anAutoNodeChoosed".tr(), //"Un noeud sûr et valide sera choisi automatiquement parmis une liste aléatoire.",
style: TextStyle(
fontSize: 15,
fontStyle: FontStyle.italic,
@ -259,7 +259,7 @@ class SettingsScreen extends StatelessWidget {
);
}),
Text(
'bloc${sub.blocNumber}',
'blockN'.tr(args: [sub.blocNumber.toString()]), //'bloc${sub.blocNumber}',
style: TextStyle(fontSize: 14, color: Colors.grey[700]),
)
],
@ -386,7 +386,7 @@ class SettingsScreen extends StatelessWidget {
height: 60,
child: Text(
sub.getConnectedEndpoint() ??
"Un noeud sûr et valide sera choisi automatiquement parmis une liste aléatoire.",
"anAutoNodeChoosed".tr(), //"Un noeud sûr et valide sera choisi automatiquement parmis une liste aléatoire.",
style: TextStyle(
fontSize: 15,
fontStyle: FontStyle.italic,

View File

@ -1,3 +1,4 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:gecko/globals.dart';
import 'package:gecko/models/g1_wallets_list.dart';
@ -55,8 +56,11 @@ class NameByAddress extends StatelessWidget {
),
builder: (QueryResult result,
{VoidCallback? refetch, FetchMore? fetchMore}) {
if (result.hasException) {
return Text(result.exception.toString());
if (kDebugMode) {
if (result.hasException) {
return Text(result.exception.toString());
}
}
if (result.isLoading) {

View File

@ -1,4 +1,5 @@
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:gecko/globals.dart';
import 'package:gecko/models/queries_indexer.dart';
@ -24,7 +25,7 @@ class SearchIdentityQuery extends StatelessWidget {
final duniterIndexer = Provider.of<DuniterIndexer>(context, listen: false);
final searchProvider = Provider.of<SearchProvider>(context, listen: false);
if (indexerEndpoint == '') {
return const Text('Aucun résultat');
return Text('noResult'.tr());
}
log.d(indexerEndpoint);
@ -52,8 +53,11 @@ class SearchIdentityQuery extends StatelessWidget {
),
builder: (QueryResult result,
{VoidCallback? refetch, FetchMore? fetchMore}) {
if (result.hasException) {
return Text(result.exception.toString());
if (kDebugMode) {
if (result.hasException) {
return Text(result.exception.toString());
}
}
if (result.isLoading) {