2020-08-25 16:32:40 +00:00
|
|
|
import 'package:flutter/foundation.dart';
|
2020-06-01 18:13:56 +00:00
|
|
|
import 'package:mobx/mobx.dart';
|
2020-09-21 11:50:26 +00:00
|
|
|
import 'package:cake_wallet/entities/transaction_info.dart';
|
2020-06-01 18:13:56 +00:00
|
|
|
|
2020-06-20 07:10:00 +00:00
|
|
|
abstract class TransactionHistoryBase<TransactionType extends TransactionInfo> {
|
2021-05-07 07:36:38 +00:00
|
|
|
TransactionHistoryBase();
|
|
|
|
// : _isUpdating = false;
|
2020-06-01 18:13:56 +00:00
|
|
|
|
|
|
|
@observable
|
2020-08-25 16:32:40 +00:00
|
|
|
ObservableMap<String, TransactionType> transactions;
|
2020-06-01 18:13:56 +00:00
|
|
|
|
2021-05-07 07:36:38 +00:00
|
|
|
Future<void> save();
|
|
|
|
|
|
|
|
void addOne(TransactionType transaction);
|
|
|
|
|
|
|
|
void addMany(Map<String, TransactionType> transactions);
|
|
|
|
|
|
|
|
// bool _isUpdating;
|
|
|
|
|
|
|
|
// @action
|
|
|
|
// Future<void> update() async {
|
|
|
|
// if (_isUpdating) {
|
|
|
|
// return;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// try {
|
|
|
|
// _isUpdating = true;
|
|
|
|
// final _transactions = await fetchTransactions();
|
|
|
|
// transactions.keys
|
|
|
|
// .toSet()
|
|
|
|
// .difference(_transactions.keys.toSet())
|
|
|
|
// .forEach((k) => transactions.remove(k));
|
|
|
|
// _transactions.forEach((key, value) => transactions[key] = value);
|
|
|
|
// _isUpdating = false;
|
|
|
|
// } catch (e) {
|
|
|
|
// _isUpdating = false;
|
|
|
|
// rethrow;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
// void updateAsync({void Function() onFinished}) {
|
|
|
|
// fetchTransactionsAsync(
|
|
|
|
// (transaction) => transactions[transaction.id] = transaction,
|
|
|
|
// onFinished: onFinished);
|
|
|
|
// }
|
|
|
|
|
|
|
|
// void fetchTransactionsAsync(
|
|
|
|
// void Function(TransactionType transaction) onTransactionLoaded,
|
|
|
|
// {void Function() onFinished});
|
|
|
|
|
|
|
|
// Future<Map<String, TransactionType>> fetchTransactions();
|
2020-08-25 16:32:40 +00:00
|
|
|
}
|