Skip to content

Commit 73ecda8

Browse files
authored
Merge pull request #60 from flutter-news-app-full-source-code/fix-remote-config-post
Fix remote config post
2 parents be4d257 + ea051a3 commit 73ecda8

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
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(

lib/main.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import 'package:flutter_news_app_web_dashboard_full_source_code/app/config/confi
66
import 'package:flutter_news_app_web_dashboard_full_source_code/bootstrap.dart';
77

88
// Define the current application environment (production/development/demo).
9-
const AppEnvironment appEnvironment = AppEnvironment.demo;
9+
const AppEnvironment appEnvironment = AppEnvironment.development;
1010

1111
@JS('removeSplashFromWeb')
1212
external void removeSplashFromWeb();

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)