mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2025-09-18 15:26:40 +00:00
fixed editing
This commit is contained in:
parent
3b9d93b9a8
commit
2fcda9bf24
1 changed files with 16 additions and 4 deletions
|
@ -60,10 +60,22 @@ sealed class IEquipmentProfileEditBloc<T extends IEquipmentProfile>
|
|||
|
||||
Future<void> _onSave(EquipmentProfileSaveEvent<T> _, Emitter emit) async {
|
||||
emit(state.copyWith(isLoading: true));
|
||||
final profileId = isEdit ? originalEquipmentProfile.id : const Uuid().v1();
|
||||
final newProfile = await createProfile(profileId);
|
||||
assert(newProfile.id == profileId, 'The new profile id must be the same as the original profile id');
|
||||
if (isEdit) {
|
||||
final newProfile = await createProfile(originalEquipmentProfile.id);
|
||||
assert(
|
||||
newProfile.id == originalEquipmentProfile.id,
|
||||
'The edited profile id must be the same as the original profile id',
|
||||
);
|
||||
await profilesProvider.updateProfile(newProfile);
|
||||
} else {
|
||||
final newId = const Uuid().v1();
|
||||
final newProfile = await createProfile(newId);
|
||||
assert(
|
||||
newProfile.id == newId,
|
||||
'A profile to be added must have a unique id.',
|
||||
);
|
||||
await profilesProvider.addProfile(newProfile);
|
||||
}
|
||||
emit(state.copyWith(isLoading: false));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue