Skip to content

Commit 8379096

Browse files
committed
fix(content_management): improve source updating functionality
- Use original source data for attributes not directly edited by the user - Remove redundant source creation and simplify the update process - Ensure createdAt timestamp remains unchanged during updates
1 parent f8dd61e commit 8379096

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

lib/content_management/bloc/edit_source/edit_source_bloc.dart

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -146,17 +146,15 @@ class EditSourceBloc extends Bloc<EditSourceEvent, EditSourceState> {
146146

147147
emit(state.copyWith(status: EditSourceStatus.submitting));
148148
try {
149-
final updatedSource = Source(
150-
id: state.sourceId,
149+
final originalSource = await _sourcesRepository.read(id: state.sourceId);
150+
final updatedSource = originalSource.copyWith(
151151
name: state.name,
152152
description: state.description,
153153
url: state.url,
154-
sourceType: state.sourceType!,
155-
language: state.language!,
156-
headquarters: state.headquarters!,
154+
sourceType: state.sourceType,
155+
language: state.language,
156+
headquarters: state.headquarters,
157157
status: state.contentStatus,
158-
createdAt:
159-
DateTime.now(), // This should ideally be the original createdAt
160158
updatedAt: DateTime.now(),
161159
);
162160

0 commit comments

Comments
 (0)