From 564604a4c80c447defaabf0a7f0518321531882e Mon Sep 17 00:00:00 2001 From: dreautall <109872040+dreautall@users.noreply.github.com> Date: Sat, 4 Nov 2023 08:39:52 +0000 Subject: [PATCH] properly notify of stock cache clears fix #194 --- lib/pages/home/transactions.dart | 8 ++++++++ lib/stock.dart | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/pages/home/transactions.dart b/lib/pages/home/transactions.dart index 8753a3d1..37c58733 100644 --- a/lib/pages/home/transactions.dart +++ b/lib/pages/home/transactions.dart @@ -45,6 +45,7 @@ class _HomeTransactionsState extends State DateTime? _lastDate; List _rowsWithDate = []; + late TransStock stock; final TransactionFilters _filters = TransactionFilters(); @@ -104,15 +105,22 @@ class _HomeTransactionsState extends State ); }); } + + stock = context.read().transStock!; } @override void dispose() { + stock.removeListener(notifRefresh); _pagingController.dispose(); super.dispose(); } + void notifRefresh() { + _pagingController.refresh(); + } + Future _fetchPage(int pageKey) async { final TransStock? stock = context.read().transStock; diff --git a/lib/stock.dart b/lib/stock.dart index 2657219c..64741a41 100644 --- a/lib/stock.dart +++ b/lib/stock.dart @@ -2,13 +2,14 @@ import 'dart:async'; import 'dart:convert'; import 'package:chopper/chopper.dart' show Response; +import 'package:flutter/material.dart'; import 'package:stock/stock.dart'; import 'package:waterflyiii/generated/swagger_fireflyiii_api/firefly_iii.enums.swagger.dart' as enums show TransactionTypeFilter; import 'package:waterflyiii/generated/swagger_fireflyiii_api/firefly_iii.swagger.dart'; -class TransStock { +class TransStock with ChangeNotifier { final FireflyIii api; late Stock _singleStock; @@ -160,6 +161,7 @@ class TransStock { _getStock.clearAll(); _getAccountStock.clearAll(); _getSearchStock.clearAll(); + notifyListeners(); } Future setTransaction(TransactionRead transaction) async {