don't close coin's sub if coin has another wallet on the sync list

This commit is contained in:
sneurlax 2024-02-06 15:10:18 -06:00
parent f81e432d33
commit 15aeb39776

View file

@ -623,11 +623,26 @@ abstract class Wallet<T extends CryptoCurrency> {
case SyncingType.selectedWalletsAtStartup:
// Close the subscription if this wallet is not in the list to be synced.
if (!prefs.walletIdsSyncOnStartup.contains(walletId)) {
await ElectrumxChainHeightService.subscriptions[cryptoCurrency.coin]
?.cancel();
// Check if there's another wallet of this coin on the sync list.
List<String> walletIds = [];
for (final id in prefs.walletIdsSyncOnStartup) {
final wallet = mainDB.isar.walletInfo
.where()
.walletIdEqualTo(id)
.findFirstSync()!;
if (wallet.coin == cryptoCurrency.coin) {
walletIds.add(id);
}
}
// TODO [prio=low]: use a query instead of iterating thru wallets.
// If there are no other wallets of this coin, then close the sub.
if (walletIds.isEmpty) {
await ElectrumxChainHeightService.subscriptions[cryptoCurrency.coin]
?.cancel();
}
}
// TODO [prio=low]: Do not close subscription if another wallet of this coin
// is in walletIdsSyncOnStartup.
case SyncingType.allWalletsOnStartup:
// Do nothing.
break;