|
1 | 1 | import 'dart:async'; |
2 | 2 | import 'dart:ffi'; |
| 3 | +import 'dart:io'; |
3 | 4 |
|
4 | 5 | import 'package:cw_monero/api/convert_utf8_to_string.dart'; |
5 | 6 | import 'package:cw_monero/api/exceptions/setup_wallet_exception.dart'; |
@@ -358,23 +359,26 @@ int storeTime = 0; |
358 | 359 | bool priorityInQueue = false; |
359 | 360 |
|
360 | 361 | Future<bool> store({bool prioritySave = false}) async { |
361 | | - // if (priorityInQueue) { |
362 | | - // return false; |
363 | | - // } |
364 | | - // print( |
365 | | - // "${DateTime.now().millisecondsSinceEpoch} $prioritySave $priorityInQueue"); |
366 | | - // if (DateTime.now().millisecondsSinceEpoch < storeTime + 90000 && |
367 | | - // prioritySave) { |
368 | | - // priorityInQueue = true; |
369 | | - // await Future.delayed(Duration(seconds: 1)); |
370 | | - // priorityInQueue = false; |
371 | | - // return store(prioritySave: prioritySave); |
372 | | - // } else if (DateTime.now().millisecondsSinceEpoch < storeTime + 90000 && |
373 | | - // !prioritySave) { |
374 | | - // return false; |
375 | | - // } |
376 | | - // print("released $storeTime"); |
377 | | - // storeTime = DateTime.now().millisecondsSinceEpoch; |
| 362 | + // Delay saves |
| 363 | + if (Platform.isAndroid) { |
| 364 | + if (priorityInQueue) { |
| 365 | + return false; |
| 366 | + } |
| 367 | + print( |
| 368 | + "${DateTime.now().millisecondsSinceEpoch} $prioritySave $priorityInQueue"); |
| 369 | + if (DateTime.now().millisecondsSinceEpoch < storeTime + 90000 && |
| 370 | + prioritySave) { |
| 371 | + priorityInQueue = true; |
| 372 | + await Future.delayed(Duration(seconds: 1)); |
| 373 | + priorityInQueue = false; |
| 374 | + return store(prioritySave: prioritySave); |
| 375 | + } else if (DateTime.now().millisecondsSinceEpoch < storeTime + 90000 && |
| 376 | + !prioritySave) { |
| 377 | + return false; |
| 378 | + } |
| 379 | + print("released $storeTime"); |
| 380 | + storeTime = DateTime.now().millisecondsSinceEpoch; |
| 381 | + } |
378 | 382 | await compute<int, void>(_storeSync, 0); |
379 | 383 | return true; |
380 | 384 | } |
|
0 commit comments