Skip to content

Commit 394f469

Browse files
committed
fix (bandaid?) xelis open-close-open wallet quickly bug
1 parent ba89365 commit 394f469

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

lib/wallets/wallet/intermediate/lib_xelis_wallet.dart

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,10 @@ abstract class LibXelisWallet<T extends ElectrumCurrency>
327327

328328
@override
329329
Future<void> open() async {
330+
while (exitInProgress) {
331+
await Future<void>.delayed(const Duration(milliseconds: 500));
332+
}
333+
330334
try {
331335
await connect();
332336
} catch (e) {
@@ -339,18 +343,25 @@ abstract class LibXelisWallet<T extends ElectrumCurrency>
339343
unawaited(refresh());
340344
}
341345

346+
bool exitInProgress = false;
347+
342348
@override
343349
Future<void> exit() async {
344-
await refreshMutex.protect(() async {
345-
timer?.cancel();
346-
timer = null;
347-
348-
await _eventSubscription?.cancel();
349-
_eventSubscription = null;
350-
351-
await libXelisWallet?.offlineMode();
352-
await super.exit();
353-
});
350+
exitInProgress = true;
351+
try {
352+
await refreshMutex.protect(() async {
353+
timer?.cancel();
354+
timer = null;
355+
356+
await _eventSubscription?.cancel();
357+
_eventSubscription = null;
358+
359+
await libXelisWallet?.offlineMode();
360+
await super.exit();
361+
});
362+
} finally {
363+
exitInProgress = false;
364+
}
354365
}
355366

356367
void invalidSeedLengthCheck(int length) {

0 commit comments

Comments
 (0)