diff --git a/modules/legacy/modules/location/lib/src/features/location/presentation/location_screen.dart b/modules/legacy/modules/location/lib/src/features/location/presentation/location_screen.dart index 1582f4f7..2d1cdbec 100644 --- a/modules/legacy/modules/location/lib/src/features/location/presentation/location_screen.dart +++ b/modules/legacy/modules/location/lib/src/features/location/presentation/location_screen.dart @@ -73,11 +73,9 @@ class LocationScreen extends ConsumerWidget { .read(legacyDeviceViewModelProvider.notifier) .setSelectedDevice(device); }, - onRefreshPosition: () { - ref - .read(legacyDeviceViewModelProvider.notifier) - .refreshPositions(); - }, + onRefreshPosition: () => ref + .read(legacyDeviceViewModelProvider.notifier) + .refreshPositions(), ), ); } diff --git a/modules/legacy/modules/location/lib/src/features/location/presentation/widgets/location_map.dart b/modules/legacy/modules/location/lib/src/features/location/presentation/widgets/location_map.dart index c68d562b..f0331119 100644 --- a/modules/legacy/modules/location/lib/src/features/location/presentation/widgets/location_map.dart +++ b/modules/legacy/modules/location/lib/src/features/location/presentation/widgets/location_map.dart @@ -47,7 +47,7 @@ class LocationMap extends ConsumerStatefulWidget { final bool showRouteTrail; final bool isLoadingHistory; final ValueChanged onDeviceChanged; - final VoidCallback onRefreshPosition; + final Future Function() onRefreshPosition; const LocationMap({ super.key, @@ -685,9 +685,14 @@ class _LocationMapState extends ConsumerState unawaited( ref.read(sfTrackingProvider).legacyLocationMapRefreshTapped(), ); - widget.onRefreshPosition(); - if (!mounted) return; - await showInfoDialog(context, I18n.locationMapRefreshRequested); + try { + await widget.onRefreshPosition(); + if (!mounted) return; + await showSuccessDialog(context, I18n.positionUpdated); + } catch (_) { + if (!mounted) return; + await showErrorDialog(context, I18n.errorPositions); + } }, onCenterTap: _centerOnDevice, onToggleFollow: () async { diff --git a/packages/sf_shared/lib/src/data/models/get_devices_response_model.dart b/packages/sf_shared/lib/src/data/models/get_devices_response_model.dart index ad4ac45d..03b0f7d1 100644 --- a/packages/sf_shared/lib/src/data/models/get_devices_response_model.dart +++ b/packages/sf_shared/lib/src/data/models/get_devices_response_model.dart @@ -37,7 +37,7 @@ abstract class GetDevicesItemResponseModel with _$GetDevicesItemResponseModel { String? simId, String? simStatus, Map? paymentOptions, - required bool queueCommands, + @Default(false) bool queueCommands, required Map settings, required String connectionServer, required String protocol, diff --git a/packages/sf_shared/lib/src/data/models/get_devices_response_model.freezed.dart b/packages/sf_shared/lib/src/data/models/get_devices_response_model.freezed.dart index 88bef28b..18bae0fb 100644 --- a/packages/sf_shared/lib/src/data/models/get_devices_response_model.freezed.dart +++ b/packages/sf_shared/lib/src/data/models/get_devices_response_model.freezed.dart @@ -506,7 +506,7 @@ return $default(_that.id,_that.identificator,_that.battery,_that.userId,_that.co @JsonSerializable() class _GetDevicesItemResponseModel implements GetDevicesItemResponseModel { - const _GetDevicesItemResponseModel({required this.id, required this.identificator, this.battery, this.userId, this.companyId, this.delegationId, this.groupId, required final Map flags, final List? tags, this.lastConnection, this.carrierGenre, this.carrierBirthday, this.carrierWeight, this.carrierStepLength, required this.carrierName, this.comment, this.phone, this.simId, this.simStatus, final Map? paymentOptions, required this.queueCommands, required final Map settings, required this.connectionServer, required this.protocol, required this.type, final Map? capabilities, this.backgroundImageId, required this.createdAt, this.updatedAt}): _flags = flags,_tags = tags,_paymentOptions = paymentOptions,_settings = settings,_capabilities = capabilities; + const _GetDevicesItemResponseModel({required this.id, required this.identificator, this.battery, this.userId, this.companyId, this.delegationId, this.groupId, required final Map flags, final List? tags, this.lastConnection, this.carrierGenre, this.carrierBirthday, this.carrierWeight, this.carrierStepLength, required this.carrierName, this.comment, this.phone, this.simId, this.simStatus, final Map? paymentOptions, this.queueCommands = false, required final Map settings, required this.connectionServer, required this.protocol, required this.type, final Map? capabilities, this.backgroundImageId, required this.createdAt, this.updatedAt}): _flags = flags,_tags = tags,_paymentOptions = paymentOptions,_settings = settings,_capabilities = capabilities; factory _GetDevicesItemResponseModel.fromJson(Map json) => _$GetDevicesItemResponseModelFromJson(json); @override final String id; @@ -551,7 +551,7 @@ class _GetDevicesItemResponseModel implements GetDevicesItemResponseModel { return EqualUnmodifiableMapView(value); } -@override final bool queueCommands; +@override@JsonKey() final bool queueCommands; final Map _settings; @override Map get settings { if (_settings is EqualUnmodifiableMapView) return _settings; diff --git a/packages/sf_shared/lib/src/data/models/get_devices_response_model.g.dart b/packages/sf_shared/lib/src/data/models/get_devices_response_model.g.dart index c13d4d30..b6baffed 100644 --- a/packages/sf_shared/lib/src/data/models/get_devices_response_model.g.dart +++ b/packages/sf_shared/lib/src/data/models/get_devices_response_model.g.dart @@ -43,7 +43,7 @@ _GetDevicesItemResponseModel _$GetDevicesItemResponseModelFromJson( simId: json['simId'] as String?, simStatus: json['simStatus'] as String?, paymentOptions: json['paymentOptions'] as Map?, - queueCommands: json['queueCommands'] as bool, + queueCommands: json['queueCommands'] as bool? ?? false, settings: json['settings'] as Map, connectionServer: json['connectionServer'] as String, protocol: json['protocol'] as String,