Skip to content

Commit 88f3541

Browse files
committed
refactor(content_management): emit created source object on success
1 parent 669f860 commit 88f3541

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/content_management/bloc/create_source/create_source_bloc.dart

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,18 +124,26 @@ class CreateSourceBloc extends Bloc<CreateSourceEvent, CreateSourceState> {
124124

125125
emit(state.copyWith(status: CreateSourceStatus.submitting));
126126
try {
127+
final now = DateTime.now();
127128
final newSource = Source(
128129
name: state.name,
129130
description: state.description.isNotEmpty ? state.description : null,
130131
url: state.url.isNotEmpty ? state.url : null,
131132
sourceType: state.sourceType,
132133
language: state.language.isNotEmpty ? state.language : null,
134+
createdAt: now,
135+
updatedAt: now,
133136
headquarters: state.headquarters,
134137
status: state.contentStatus,
135138
);
136139

137140
await _sourcesRepository.create(item: newSource);
138-
emit(state.copyWith(status: CreateSourceStatus.success));
141+
emit(
142+
state.copyWith(
143+
status: CreateSourceStatus.success,
144+
createdSource: newSource,
145+
),
146+
);
139147
} on HtHttpException catch (e) {
140148
emit(
141149
state.copyWith(

0 commit comments

Comments
 (0)