Skip to content

Commit d87412d

Browse files
committed
refactor(content_management): emit created headline object on success
1 parent cd46a81 commit d87412d

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/content_management/bloc/create_headline/create_headline_bloc.dart

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,18 +135,27 @@ class CreateHeadlineBloc
135135

136136
emit(state.copyWith(status: CreateHeadlineStatus.submitting));
137137
try {
138+
final now = DateTime.now();
138139
final newHeadline = Headline(
139140
title: state.title,
140141
description: state.description.isNotEmpty ? state.description : null,
141142
url: state.url.isNotEmpty ? state.url : null,
142143
imageUrl: state.imageUrl.isNotEmpty ? state.imageUrl : null,
143144
source: state.source,
145+
publishedAt: now,
146+
createdAt: now,
147+
updatedAt: now,
144148
category: state.category,
145149
status: state.contentStatus,
146150
);
147151

148152
await _headlinesRepository.create(item: newHeadline);
149-
emit(state.copyWith(status: CreateHeadlineStatus.success));
153+
emit(
154+
state.copyWith(
155+
status: CreateHeadlineStatus.success,
156+
createdHeadline: newHeadline,
157+
),
158+
);
150159
} on HtHttpException catch (e) {
151160
emit(
152161
state.copyWith(

0 commit comments

Comments
 (0)