Skip to content

Commit ea051a3

Browse files
committed
fix(app_configuration): handle missing original remote config and update config logic
- Add null check for originalRemoteConfig and handle failure case - Update remote config update logic to include createdAt and updatedAt timestamps
1 parent 10f47ef commit ea051a3

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

lib/app_configuration/bloc/app_configuration_bloc.dart

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,26 @@ class AppConfigurationBloc
5757
AppConfigurationUpdated event,
5858
Emitter<AppConfigurationState> emit,
5959
) async {
60+
if (state.originalRemoteConfig == null) {
61+
emit(
62+
state.copyWith(
63+
status: AppConfigurationStatus.failure,
64+
exception: const UnknownException(
65+
'Original remote config is not available.',
66+
),
67+
),
68+
);
69+
return;
70+
}
6071
emit(state.copyWith(status: AppConfigurationStatus.loading));
6172
try {
73+
final configToUpdate = event.remoteConfig.copyWith(
74+
createdAt: state.originalRemoteConfig!.createdAt,
75+
updatedAt: DateTime.now(),
76+
);
6277
final updatedConfig = await _remoteConfigRepository.update(
63-
id: event.remoteConfig.id,
64-
item: event.remoteConfig,
78+
id: configToUpdate.id,
79+
item: configToUpdate,
6580
);
6681
emit(
6782
state.copyWith(

pubspec.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ packages:
9090
description:
9191
path: "."
9292
ref: HEAD
93-
resolved-ref: "7a1b54f8c0f94f6c04af3404c8110181e080b5c4"
93+
resolved-ref: f648500814ec636a2930498756029d29b363194a
9494
url: "https://github.com/flutter-news-app-full-source-code/core.git"
9595
source: git
9696
version: "0.0.0"
@@ -269,10 +269,10 @@ packages:
269269
dependency: "direct main"
270270
description:
271271
name: go_router
272-
sha256: c489908a54ce2131f1d1b7cc631af9c1a06fac5ca7c449e959192089f9489431
272+
sha256: "8b1f37dfaf6e958c6b872322db06f946509433bec3de753c3491a42ae9ec2b48"
273273
url: "https://pub.dev"
274274
source: hosted
275-
version: "16.0.0"
275+
version: "16.1.0"
276276
google_fonts:
277277
dependency: "direct main"
278278
description:

0 commit comments

Comments
 (0)