sistemato deeplinking alla serviceformscreen, aggiunto logout e sistemate altre cose
This commit is contained in:
@@ -199,22 +199,24 @@ class ServicesCubit extends Cubit<ServicesState> {
|
||||
|
||||
// --- PERSISTENZA ---
|
||||
|
||||
Future<void> saveCurrentService() async {
|
||||
Future<void> saveCurrentService({required bool isBozza}) async {
|
||||
if (state.currentService == null) return;
|
||||
|
||||
emit(state.copyWith(status: ServicesStatus.saving, errorMessage: null));
|
||||
try {
|
||||
// Usiamo il repository corazzato che abbiamo scritto prima
|
||||
await _repository.saveFullService(state.currentService!);
|
||||
// 1. Aggiorniamo il flag bozza in base a quale pulsante ha premuto l'utente
|
||||
final serviceToSave = state.currentService!.copyWith(isBozza: isBozza);
|
||||
|
||||
await loadServices(refresh: true);
|
||||
// Reset della bozza e ricaricamento lista
|
||||
// 2. Salvataggio corazzato
|
||||
await _repository.saveFullService(serviceToSave);
|
||||
|
||||
// 3. Reset e ricaricamento
|
||||
emit(state.copyWith(status: ServicesStatus.saved, currentService: null));
|
||||
await loadServices(refresh: true);
|
||||
} catch (e) {
|
||||
emit(
|
||||
state.copyWith(
|
||||
status: ServicesStatus.failure,
|
||||
|
||||
errorMessage: e.toString(),
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user