refactoring
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
/// BLoC pour la gestion des paramètres système (Clean Architecture)
|
||||
library system_settings_bloc;
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:injectable/injectable.dart';
|
||||
import '../../domain/usecases/get_settings.dart';
|
||||
@@ -48,6 +49,7 @@ class SystemSettingsBloc extends Bloc<SystemSettingsEvent, SystemSettingsState>
|
||||
final config = await _getSettings(); // ✅ Use case
|
||||
emit(SystemConfigLoaded(config));
|
||||
} catch (e) {
|
||||
if (e is DioException && e.type == DioExceptionType.cancel) return;
|
||||
emit(SystemSettingsError('Erreur de chargement: ${e.toString()}'));
|
||||
}
|
||||
}
|
||||
@@ -62,6 +64,7 @@ class SystemSettingsBloc extends Bloc<SystemSettingsEvent, SystemSettingsState>
|
||||
emit(SystemConfigLoaded(config));
|
||||
emit(const SystemSettingsSuccess('Configuration mise à jour'));
|
||||
} catch (e) {
|
||||
if (e is DioException && e.type == DioExceptionType.cancel) return;
|
||||
emit(SystemSettingsError('Erreur de mise à jour: ${e.toString()}'));
|
||||
}
|
||||
}
|
||||
@@ -75,6 +78,7 @@ class SystemSettingsBloc extends Bloc<SystemSettingsEvent, SystemSettingsState>
|
||||
final stats = await _getCacheStats(); // ✅ Use case
|
||||
emit(CacheStatsLoaded(stats));
|
||||
} catch (e) {
|
||||
if (e is DioException && e.type == DioExceptionType.cancel) return;
|
||||
emit(SystemSettingsError('Erreur de chargement: ${e.toString()}'));
|
||||
}
|
||||
}
|
||||
@@ -101,6 +105,7 @@ class SystemSettingsBloc extends Bloc<SystemSettingsEvent, SystemSettingsState>
|
||||
await _clearCache(); // ✅ Use case
|
||||
emit(const SystemSettingsSuccess('Cache vidé avec succès'));
|
||||
} catch (e) {
|
||||
if (e is DioException && e.type == DioExceptionType.cancel) return;
|
||||
emit(SystemSettingsError('Erreur: ${e.toString()}'));
|
||||
}
|
||||
}
|
||||
@@ -120,6 +125,7 @@ class SystemSettingsBloc extends Bloc<SystemSettingsEvent, SystemSettingsState>
|
||||
emit(SystemSettingsError(message));
|
||||
}
|
||||
} catch (e) {
|
||||
if (e is DioException && e.type == DioExceptionType.cancel) return;
|
||||
emit(SystemSettingsError('Erreur de test: ${e.toString()}'));
|
||||
}
|
||||
}
|
||||
@@ -139,6 +145,7 @@ class SystemSettingsBloc extends Bloc<SystemSettingsEvent, SystemSettingsState>
|
||||
emit(SystemSettingsError(message));
|
||||
}
|
||||
} catch (e) {
|
||||
if (e is DioException && e.type == DioExceptionType.cancel) return;
|
||||
emit(SystemSettingsError('Erreur de test: ${e.toString()}'));
|
||||
}
|
||||
}
|
||||
@@ -154,6 +161,7 @@ class SystemSettingsBloc extends Bloc<SystemSettingsEvent, SystemSettingsState>
|
||||
emit(SystemConfigLoaded(config));
|
||||
emit(const SystemSettingsSuccess('Configuration réinitialisée'));
|
||||
} catch (e) {
|
||||
if (e is DioException && e.type == DioExceptionType.cancel) return;
|
||||
emit(SystemSettingsError('Erreur de réinitialisation: ${e.toString()}'));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user