Skip to content

Commit fe84a93

Browse files
committed
refactor(content_management): improve headline update process
- Remove unnecessary fields and null assertions - Preserve original createdAt timestamp - Use copyWith for updating headline object
1 parent 20ba806 commit fe84a93

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

lib/content_management/bloc/edit_headline/edit_headline_bloc.dart

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -163,18 +163,17 @@ class EditHeadlineBloc extends Bloc<EditHeadlineEvent, EditHeadlineState> {
163163

164164
emit(state.copyWith(status: EditHeadlineStatus.submitting));
165165
try {
166-
final updatedHeadline = Headline(
167-
id: state.headlineId,
166+
final originalHeadline =
167+
await _headlinesRepository.read(id: state.headlineId);
168+
final updatedHeadline = originalHeadline.copyWith(
168169
title: state.title,
169170
excerpt: state.excerpt,
170171
url: state.url,
171172
imageUrl: state.imageUrl,
172-
source: state.source!,
173-
topic: state.topic!,
174-
eventCountry: state.eventCountry!,
173+
source: state.source,
174+
topic: state.topic,
175+
eventCountry: state.eventCountry,
175176
status: state.contentStatus,
176-
createdAt:
177-
DateTime.now(), // This should ideally be the original createdAt
178177
updatedAt: DateTime.now(),
179178
);
180179

0 commit comments

Comments
 (0)