Skip to content

Commit c664da1

Browse files
authored
Bugfix: Favourite balance refresh (#12)
The purpose of this branch is to fix not refreshing favourite balance right after sending tokens. Additionally, it was noticed that on desktop view, adding balances to favourites is broken if there is one record, because emitting list with changed favourites by InfinityListBloc does not cause SliverInfinityList to reload. So this issue was also examined on this branch. List of changes: - added missing "forceRequestBool" parameter while calling initFavourites() in _mapListReloadEventToState() method in a_list_bloc.dart. It allowed refreshing balances by avoiding getting them from cache. - added emit(ListLoadingState()) in _mapListUpdatedEventToState() method in infinity_list_bloc.dart, to ensure the SliverInfinityList is reloaded with each emit, and the favourites will be updated. However, this is not the optimal solution, it may be necessary to rebuild the lists to manage this issue properly. Details can be found in "unify-list_items" ticket on Trello.
1 parent 9907638 commit c664da1

3 files changed

Lines changed: 7 additions & 3 deletions

File tree

lib/blocs/widgets/kira/kira_list/abstract_list/a_list_bloc.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import 'dart:async';
1+
import 'dart:async';
22

33
import 'package:flutter/cupertino.dart';
44
import 'package:flutter_bloc/flutter_bloc.dart';
@@ -149,7 +149,7 @@ abstract class AListBloc<T extends AListItem> extends Bloc<AListEvent, AListStat
149149
currentPageData = PageData<T>.initial();
150150
lastPageIndex = 0;
151151

152-
await favouritesBloc?.initFavourites();
152+
await favouritesBloc?.initFavourites(forceRequestBool: true);
153153

154154
bool filtersEnabledBool = filtersBloc?.state is FiltersActiveState<T>;
155155
bool sortEnabledBool = sortBloc != null;

lib/blocs/widgets/kira/kira_list/infinity_list/infinity_list_bloc.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import 'package:miro/blocs/widgets/kira/kira_list/abstract_list/events/list_upda
77
import 'package:miro/blocs/widgets/kira/kira_list/abstract_list/models/a_list_item.dart';
88
import 'package:miro/blocs/widgets/kira/kira_list/abstract_list/models/page_data.dart';
99
import 'package:miro/blocs/widgets/kira/kira_list/abstract_list/states/list_loaded_state.dart';
10+
import 'package:miro/blocs/widgets/kira/kira_list/abstract_list/states/list_loading_state.dart';
1011
import 'package:miro/blocs/widgets/kira/kira_list/favourites/favourites_bloc.dart';
1112
import 'package:miro/blocs/widgets/kira/kira_list/filters/filters_bloc.dart';
1213
import 'package:miro/blocs/widgets/kira/kira_list/infinity_list/events/infinity_list_reached_bottom_event.dart';
@@ -58,6 +59,9 @@ class InfinityListBloc<T extends AListItem> extends AListBloc<T> {
5859
end: (lastPageIndex + 1) * singlePageSize,
5960
);
6061

62+
// Loading state was added only to ensure loading state is always emitted.
63+
// In BLoC, if next state is recognized as the same as previous state, it will not be emitted.
64+
emit(ListLoadingState());
6165
emit(ListLoadedState<T>(
6266
listItems: visibleListItems,
6367
lastPage: currentPageData.lastPageBool,

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
1212
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
1313
# Read more about iOS versioning at
1414
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
15-
version: 1.28.0
15+
version: 1.28.1
1616

1717
environment:
1818
sdk: ">=3.1.3"

0 commit comments

Comments
 (0)