Catch Hetzner metrics trying to emit when closed and disable logging.

pull/116/head
Inex Code 2022-09-09 17:58:01 +03:00
parent 11885b7ac7
commit ef7d906504
2 changed files with 6 additions and 2 deletions

View File

@ -45,6 +45,10 @@ class HetznerMetricsCubit extends Cubit<HetznerMetricsState> {
() => load(newState.period), () => load(newState.period),
); );
emit(newState); try {
emit(newState);
} on StateError {
print('Tried to emit Hetzner metrics when cubit is closed');
}
} }
} }

View File

@ -21,7 +21,7 @@ class HetznerMetricsRepository {
break; break;
} }
final HetznerApi api = HetznerApi(hasLogger: true); final HetznerApi api = HetznerApi(hasLogger: false);
final List<Map<String, dynamic>> results = await Future.wait([ final List<Map<String, dynamic>> results = await Future.wait([
api.getMetrics(start, end, 'cpu'), api.getMetrics(start, end, 'cpu'),