Skip to content

Commit

Permalink
properly notify of stock cache clears
Browse files Browse the repository at this point in the history
fix #194
  • Loading branch information
dreautall committed Nov 4, 2023
1 parent 3df4358 commit 564604a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 8 additions & 0 deletions lib/pages/home/transactions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class _HomeTransactionsState extends State<HomeTransactions>

DateTime? _lastDate;
List<int> _rowsWithDate = <int>[];
late TransStock stock;

final TransactionFilters _filters = TransactionFilters();

Expand Down Expand Up @@ -104,15 +105,22 @@ class _HomeTransactionsState extends State<HomeTransactions>
);
});
}

stock = context.read<FireflyService>().transStock!;
}

@override
void dispose() {
stock.removeListener(notifRefresh);
_pagingController.dispose();

super.dispose();
}

void notifRefresh() {
_pagingController.refresh();
}

Future<void> _fetchPage(int pageKey) async {
final TransStock? stock = context.read<FireflyService>().transStock;

Expand Down
4 changes: 3 additions & 1 deletion lib/stock.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, TransactionRead> _singleStock;
Expand Down Expand Up @@ -160,6 +161,7 @@ class TransStock {
_getStock.clearAll();
_getAccountStock.clearAll();
_getSearchStock.clearAll();
notifyListeners();
}

Future<void> setTransaction(TransactionRead transaction) async {
Expand Down

0 comments on commit 564604a

Please sign in to comment.