fix(location): add refresh success feedback and fix queueCommands null crash

This commit is contained in:
2026-04-26 05:41:21 +02:00
parent bef87262b1
commit 2d87cd5aee
5 changed files with 16 additions and 13 deletions

View File

@@ -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(),
),
);
}

View File

@@ -47,7 +47,7 @@ class LocationMap extends ConsumerStatefulWidget {
final bool showRouteTrail;
final bool isLoadingHistory;
final ValueChanged<DeviceEntity> onDeviceChanged;
final VoidCallback onRefreshPosition;
final Future<void> Function() onRefreshPosition;
const LocationMap({
super.key,
@@ -685,9 +685,14 @@ class _LocationMapState extends ConsumerState<LocationMap>
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 {

View File

@@ -37,7 +37,7 @@ abstract class GetDevicesItemResponseModel with _$GetDevicesItemResponseModel {
String? simId,
String? simStatus,
Map<String, dynamic>? paymentOptions,
required bool queueCommands,
@Default(false) bool queueCommands,
required Map<String, dynamic> settings,
required String connectionServer,
required String protocol,

View File

@@ -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<String, dynamic> flags, final List<String>? tags, this.lastConnection, this.carrierGenre, this.carrierBirthday, this.carrierWeight, this.carrierStepLength, required this.carrierName, this.comment, this.phone, this.simId, this.simStatus, final Map<String, dynamic>? paymentOptions, required this.queueCommands, required final Map<String, dynamic> settings, required this.connectionServer, required this.protocol, required this.type, final Map<String, dynamic>? 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<String, dynamic> flags, final List<String>? tags, this.lastConnection, this.carrierGenre, this.carrierBirthday, this.carrierWeight, this.carrierStepLength, required this.carrierName, this.comment, this.phone, this.simId, this.simStatus, final Map<String, dynamic>? paymentOptions, this.queueCommands = false, required final Map<String, dynamic> settings, required this.connectionServer, required this.protocol, required this.type, final Map<String, dynamic>? capabilities, this.backgroundImageId, required this.createdAt, this.updatedAt}): _flags = flags,_tags = tags,_paymentOptions = paymentOptions,_settings = settings,_capabilities = capabilities;
factory _GetDevicesItemResponseModel.fromJson(Map<String, dynamic> 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<String, dynamic> _settings;
@override Map<String, dynamic> get settings {
if (_settings is EqualUnmodifiableMapView) return _settings;

View File

@@ -43,7 +43,7 @@ _GetDevicesItemResponseModel _$GetDevicesItemResponseModelFromJson(
simId: json['simId'] as String?,
simStatus: json['simStatus'] as String?,
paymentOptions: json['paymentOptions'] as Map<String, dynamic>?,
queueCommands: json['queueCommands'] as bool,
queueCommands: json['queueCommands'] as bool? ?? false,
settings: json['settings'] as Map<String, dynamic>,
connectionServer: json['connectionServer'] as String,
protocol: json['protocol'] as String,