mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-10 20:54:33 +00:00
init cache db no matter what on startup
This commit is contained in:
parent
9974f60b4c
commit
2ff27956d1
7 changed files with 11 additions and 24 deletions
|
@ -293,11 +293,11 @@ class _MaterialAppWithThemeState extends ConsumerState<MaterialAppWithTheme>
|
|||
// TODO: this should probably run unawaited. Keep commented out for now as proper community nodes ui hasn't been implemented yet
|
||||
// unawaited(_nodeService.updateCommunityNodes());
|
||||
|
||||
await ExchangeDataLoadingService.instance.initDB();
|
||||
// run without awaiting
|
||||
if (ref.read(prefsChangeNotifierProvider).externalCalls &&
|
||||
await ref.read(prefsChangeNotifierProvider).isExternalCallsSet()) {
|
||||
if (Constants.enableExchange) {
|
||||
await ExchangeDataLoadingService.instance.init();
|
||||
await ExchangeDataLoadingService.instance.setCurrenciesIfEmpty(
|
||||
ref.read(exchangeFormStateProvider),
|
||||
);
|
||||
|
|
|
@ -3,6 +3,7 @@ import 'dart:async';
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:stackwallet/db/isar/main_db.dart';
|
||||
import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart';
|
||||
import 'package:stackwallet/pages/exchange_view/exchange_form.dart';
|
||||
import 'package:stackwallet/pages/exchange_view/trade_details_view.dart';
|
||||
|
@ -17,8 +18,6 @@ import 'package:stackwallet/widgets/custom_loading_overlay.dart';
|
|||
import 'package:stackwallet/widgets/trade_card.dart';
|
||||
import 'package:tuple/tuple.dart';
|
||||
|
||||
import '../../db/isar/main_db.dart';
|
||||
|
||||
class ExchangeView extends ConsumerStatefulWidget {
|
||||
const ExchangeView({Key? key}) : super(key: key);
|
||||
|
||||
|
@ -46,9 +45,7 @@ class _ExchangeViewState extends ConsumerState<ExchangeView> {
|
|||
});
|
||||
};
|
||||
}
|
||||
ExchangeDataLoadingService.instance
|
||||
.init()
|
||||
.then((_) => ExchangeDataLoadingService.instance.loadAll());
|
||||
ExchangeDataLoadingService.instance.loadAll();
|
||||
} else if (ExchangeDataLoadingService.instance.isLoading &&
|
||||
ExchangeDataLoadingService.currentCacheVersion <
|
||||
ExchangeDataLoadingService.cacheVersion) {
|
||||
|
|
|
@ -62,9 +62,7 @@ class _WalletInitiatedExchangeViewState
|
|||
});
|
||||
};
|
||||
}
|
||||
ExchangeDataLoadingService.instance
|
||||
.init()
|
||||
.then((_) => ExchangeDataLoadingService.instance.loadAll());
|
||||
ExchangeDataLoadingService.instance.loadAll();
|
||||
} else if (ExchangeDataLoadingService.instance.isLoading &&
|
||||
ExchangeDataLoadingService.currentCacheVersion <
|
||||
ExchangeDataLoadingService.cacheVersion) {
|
||||
|
|
|
@ -236,10 +236,7 @@ class _StackPrivacyCalls extends ConsumerState<StackPrivacyCalls> {
|
|||
if (isEasy) {
|
||||
unawaited(
|
||||
ExchangeDataLoadingService.instance
|
||||
.init()
|
||||
.then((_) => ExchangeDataLoadingService
|
||||
.instance
|
||||
.loadAll()),
|
||||
.loadAll(),
|
||||
);
|
||||
// unawaited(
|
||||
// BuyDataLoadingService().loadAll(ref));
|
||||
|
|
|
@ -284,12 +284,8 @@ class _WalletViewState extends ConsumerState<WalletView> {
|
|||
.tickerEqualToAnyExchangeNameName(coin.ticker)
|
||||
.findFirst();
|
||||
} catch (_) {
|
||||
_future = ExchangeDataLoadingService.instance
|
||||
.init()
|
||||
.then(
|
||||
(_) => ExchangeDataLoadingService.instance.loadAll(),
|
||||
)
|
||||
.then((_) => ExchangeDataLoadingService.instance.isar.currencies
|
||||
_future = ExchangeDataLoadingService.instance.loadAll().then((_) =>
|
||||
ExchangeDataLoadingService.instance.isar.currencies
|
||||
.where()
|
||||
.tickerEqualToAnyExchangeNameName(coin.ticker)
|
||||
.findFirst());
|
||||
|
|
|
@ -46,9 +46,7 @@ class _DesktopExchangeViewState extends ConsumerState<DesktopExchangeView> {
|
|||
});
|
||||
};
|
||||
}
|
||||
ExchangeDataLoadingService.instance
|
||||
.init()
|
||||
.then((_) => ExchangeDataLoadingService.instance.loadAll());
|
||||
ExchangeDataLoadingService.instance.loadAll();
|
||||
} else if (ExchangeDataLoadingService.instance.isLoading &&
|
||||
ExchangeDataLoadingService.currentCacheVersion <
|
||||
ExchangeDataLoadingService.cacheVersion) {
|
||||
|
|
|
@ -40,8 +40,9 @@ class ExchangeDataLoadingService {
|
|||
);
|
||||
}
|
||||
|
||||
Future<void> init() async {
|
||||
if (_isar != null && isar.isOpen) return;
|
||||
Future<void> initDB() async {
|
||||
if (_isar != null) return;
|
||||
await _isar?.close();
|
||||
_isar = await Isar.open(
|
||||
[
|
||||
CurrencySchema,
|
||||
|
|
Loading…
Reference in a new issue