refreshGeneratorDetailsApi function

Future<void> refreshGeneratorDetailsApi(
  1. BuildContext context,
  2. int id, {
  3. bool awaitDeviceListRefresh = false,
})

Refresh the generator details of the device with the given id using the underlying backend API calls

Implementation

Future<void> refreshGeneratorDetailsApi(
  BuildContext context,
  int id, {
  bool awaitDeviceListRefresh = false,
}) async {
  // Refreshing all devices since part of generator details includes data
  // from this list. Do it in the background because this is typically slow.
  final refreshDevices = context.read(refreshCachedDevicesProvider);

  if (!awaitDeviceListRefresh) {
    unawaited(refreshDevices(context));
  }

  await Future.wait([
    if (awaitDeviceListRefresh) refreshDevices(context),
    context.asyncRefresh(deviceDetailsApiFamily(id)),
  ]);
}