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) .read(legacyDeviceViewModelProvider.notifier)
.setSelectedDevice(device); .setSelectedDevice(device);
}, },
onRefreshPosition: () { onRefreshPosition: () => ref
ref
.read(legacyDeviceViewModelProvider.notifier) .read(legacyDeviceViewModelProvider.notifier)
.refreshPositions(); .refreshPositions(),
},
), ),
); );
} }

View File

@@ -47,7 +47,7 @@ class LocationMap extends ConsumerStatefulWidget {
final bool showRouteTrail; final bool showRouteTrail;
final bool isLoadingHistory; final bool isLoadingHistory;
final ValueChanged<DeviceEntity> onDeviceChanged; final ValueChanged<DeviceEntity> onDeviceChanged;
final VoidCallback onRefreshPosition; final Future<void> Function() onRefreshPosition;
const LocationMap({ const LocationMap({
super.key, super.key,
@@ -685,9 +685,14 @@ class _LocationMapState extends ConsumerState<LocationMap>
unawaited( unawaited(
ref.read(sfTrackingProvider).legacyLocationMapRefreshTapped(), ref.read(sfTrackingProvider).legacyLocationMapRefreshTapped(),
); );
widget.onRefreshPosition(); try {
await widget.onRefreshPosition();
if (!mounted) return; if (!mounted) return;
await showInfoDialog(context, I18n.locationMapRefreshRequested); await showSuccessDialog(context, I18n.positionUpdated);
} catch (_) {
if (!mounted) return;
await showErrorDialog(context, I18n.errorPositions);
}
}, },
onCenterTap: _centerOnDevice, onCenterTap: _centerOnDevice,
onToggleFollow: () async { onToggleFollow: () async {

View File

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

View File

@@ -506,7 +506,7 @@ return $default(_that.id,_that.identificator,_that.battery,_that.userId,_that.co
@JsonSerializable() @JsonSerializable()
class _GetDevicesItemResponseModel implements GetDevicesItemResponseModel { 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); factory _GetDevicesItemResponseModel.fromJson(Map<String, dynamic> json) => _$GetDevicesItemResponseModelFromJson(json);
@override final String id; @override final String id;
@@ -551,7 +551,7 @@ class _GetDevicesItemResponseModel implements GetDevicesItemResponseModel {
return EqualUnmodifiableMapView(value); return EqualUnmodifiableMapView(value);
} }
@override final bool queueCommands; @override@JsonKey() final bool queueCommands;
final Map<String, dynamic> _settings; final Map<String, dynamic> _settings;
@override Map<String, dynamic> get settings { @override Map<String, dynamic> get settings {
if (_settings is EqualUnmodifiableMapView) return _settings; if (_settings is EqualUnmodifiableMapView) return _settings;

View File

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