From a46d91593162c5d1830268f1d0bf2f908b2b314e Mon Sep 17 00:00:00 2001 From: Marcin <84280969+nemoforte@users.noreply.github.com> Date: Mon, 18 Mar 2024 10:21:30 +0100 Subject: [PATCH] Bugfix: Loading Page navigation (#5) The purpose of this branch was to examine and fix the bug related to Loading Page navigation. It could occur at the start of the application, after clicking "Cancel connection" button and connecting to a network. In case of connecting to network from assets, there was an unexpected flipping view and the Value Notifier Exception was thrown. In case of connecting to custom network (but only unhealthy), the app navigated to DashboardPage with no network connected. List of changes: - removed emit from "cancelConnection()" method in loading_page_cubit.dart. It was redundant, because adding NetworkModuleDisconnectEvent causes "_handleNetworkModuleStateChanged()", which then emits proper LoadingPageState - two states emitted in very short time caused flipping view. Also, the removed emit did not set value for NetworkModuleState, which caused "no network error". - modified "_mapAutoConnectEventToState()" method network_module_bloc.dart to prevent the "disconnected" status from being overwritten, in case of clicking "Cancel connection" button --- lib/blocs/generic/network_module/network_module_bloc.dart | 2 ++ lib/blocs/pages/loading/loading_page/loading_page_cubit.dart | 1 - .../network_custom_section/network_custom_section_cubit.dart | 2 +- pubspec.yaml | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/blocs/generic/network_module/network_module_bloc.dart b/lib/blocs/generic/network_module/network_module_bloc.dart index de2ffb04..52a4a961 100644 --- a/lib/blocs/generic/network_module/network_module_bloc.dart +++ b/lib/blocs/generic/network_module/network_module_bloc.dart @@ -107,6 +107,8 @@ class NetworkModuleBloc extends Bloc { await _networkCustomSectionCubit.updateNetworks(networkStatusModel); emit(NetworkModuleState.connected(networkStatusModel)); _refreshTokenDefaultDenomModel(networkStatusModel); + } else { + await _networkCustomSectionCubit.updateNetworks(); } } diff --git a/lib/blocs/pages/loading/loading_page/loading_page_cubit.dart b/lib/blocs/pages/loading/loading_page/loading_page_cubit.dart index 9a780a0a..12e6ec49 100644 --- a/lib/blocs/pages/loading/loading_page/loading_page_cubit.dart +++ b/lib/blocs/pages/loading/loading_page/loading_page_cubit.dart @@ -41,7 +41,6 @@ class LoadingPageCubit extends Cubit { void cancelConnection() { _networkModuleBloc.add(NetworkModuleDisconnectEvent()); - emit(LoadingPageDisconnectedState()); } Future _init() async { diff --git a/lib/blocs/widgets/network_list/network_custom_section/network_custom_section_cubit.dart b/lib/blocs/widgets/network_list/network_custom_section/network_custom_section_cubit.dart index 9856d8b3..bef652b0 100644 --- a/lib/blocs/widgets/network_list/network_custom_section/network_custom_section_cubit.dart +++ b/lib/blocs/widgets/network_list/network_custom_section/network_custom_section_cubit.dart @@ -51,7 +51,7 @@ class NetworkCustomSectionCubit extends Cubit { } } - Future updateNetworks(ANetworkStatusModel? connectedNetworkStatusModel) async { + Future updateNetworks([ANetworkStatusModel? connectedNetworkStatusModel]) async { bool customNetworkBool = _isNetworkCustom(connectedNetworkStatusModel); bool differentNetworkBool = NetworkUtils.compareUrisByUrn(connectedNetworkStatusModel?.uri, state.connectedNetworkStatusModel?.uri) == false; bool checkedNetworkBool = NetworkUtils.compareUrisByUrn(connectedNetworkStatusModel?.uri, state.checkedNetworkStatusModel?.uri); diff --git a/pubspec.yaml b/pubspec.yaml index ee633519..df03463f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -12,7 +12,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 1.22.0 +version: 1.23.0 environment: sdk: ">=3.1.3"