Skip to content

Commit d84e562

Browse files
committed
fix(app): ensure app version is set in state after version check
- Update AppBloc to set currentAppVersion in more states after version check - Modify emit statements to include currentAppVersion when updating state - Ensure consistent state updates for both version mismatch and up-to-date scenarios
1 parent e7a341e commit d84e562

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

lib/app/bloc/app_bloc.dart

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ class AppBloc extends Bloc<AppEvent, AppState> {
270270
AppVersionCheckRequested(
271271
remoteConfig: state.remoteConfig!,
272272
// Not a background check during startup
273-
isBackgroundCheck: false,
273+
isBackgroundCheck: false,
274274
),
275275
);
276276

@@ -638,7 +638,12 @@ class AppBloc extends Bloc<AppEvent, AppState> {
638638
'[AppBloc] App version ($currentVersion) is older than '
639639
'required ($latestRequiredVersion). Transitioning to updateRequired state.',
640640
);
641-
emit(state.copyWith(status: AppLifeCycleStatus.updateRequired));
641+
emit(
642+
state.copyWith(
643+
status: AppLifeCycleStatus.updateRequired,
644+
currentAppVersion: currentAppVersionString,
645+
),
646+
);
642647
} else {
643648
_logger.info(
644649
'[AppBloc] App version ($currentVersion) is up to date '
@@ -650,10 +655,16 @@ class AppBloc extends Bloc<AppEvent, AppState> {
650655
final finalStatus = state.user!.appRole == AppUserRole.standardUser
651656
? AppLifeCycleStatus.authenticated
652657
: AppLifeCycleStatus.anonymous;
653-
emit(state.copyWith(status: finalStatus));
658+
emit(
659+
state.copyWith(
660+
status: finalStatus,
661+
currentAppVersion: currentAppVersionString,
662+
),
663+
);
664+
} else {
665+
emit(state.copyWith(currentAppVersion: currentAppVersionString));
654666
}
655667
}
656-
emit(state.copyWith(currentAppVersion: currentAppVersionString));
657668
} on FormatException catch (e, s) {
658669
_logger.severe(
659670
'[AppBloc] Failed to parse app version string: $currentAppVersionString '

0 commit comments

Comments
 (0)