mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-17 01:37:54 +00:00
fix txns v2 not showing up right away on refresh
This commit is contained in:
parent
02cb79c6a3
commit
ce0b871284
1 changed files with 33 additions and 8 deletions
|
@ -8,6 +8,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
|
@ -40,6 +42,9 @@ class _TransactionsV2ListState extends ConsumerState<TransactionsV2List> {
|
|||
bool _hasLoaded = false;
|
||||
List<TransactionV2> _transactions = [];
|
||||
|
||||
late final StreamSubscription<List<TransactionV2>> _subscription;
|
||||
late final QueryBuilder<TransactionV2, TransactionV2, QAfterSortBy> _query;
|
||||
|
||||
BorderRadius get _borderRadiusFirst {
|
||||
return BorderRadius.only(
|
||||
topLeft: Radius.circular(
|
||||
|
@ -62,19 +67,39 @@ class _TransactionsV2ListState extends ConsumerState<TransactionsV2List> {
|
|||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_query = ref
|
||||
.read(mainDBProvider)
|
||||
.isar
|
||||
.transactionV2s
|
||||
.where()
|
||||
.walletIdEqualTo(widget.walletId)
|
||||
.sortByTimestampDesc();
|
||||
|
||||
_subscription = _query.watch().listen((event) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
setState(() {
|
||||
_transactions = event;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_subscription.cancel();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final coin = ref.watch(pWallets).getWallet(widget.walletId).info.coin;
|
||||
|
||||
return FutureBuilder(
|
||||
future: ref
|
||||
.watch(mainDBProvider)
|
||||
.isar
|
||||
.transactionV2s
|
||||
.where()
|
||||
.walletIdEqualTo(widget.walletId)
|
||||
.sortByTimestampDesc()
|
||||
.findAll(),
|
||||
future: _query.findAll(),
|
||||
builder: (fbContext, AsyncSnapshot<List<TransactionV2>> snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done &&
|
||||
snapshot.hasData) {
|
||||
|
|
Loading…
Reference in a new issue