fix: Stabilize reported tests #31

ref: #32 #37
This commit is contained in:
Janez T
2026-04-26 08:24:07 +02:00
parent 2fe125d6ba
commit 0008eff1b8
6 changed files with 63 additions and 23 deletions

View File

@@ -1263,11 +1263,17 @@ class ContactsProvider with ChangeNotifier {
Map<String, dynamic>? existingExtraSensorData,
Map<String, dynamic>? incomingExtraSensorData,
) {
final merged = <String, dynamic>{...?existingExtraSensorData};
if (incomingExtraSensorData == null || incomingExtraSensorData.isEmpty) {
return merged;
return <String, dynamic>{...?existingExtraSensorData};
}
final isFullTelemetryRefresh = incomingExtraSensorData.containsKey(
_rawTelemetryHexKey,
);
final merged = <String, dynamic>{
if (!isFullTelemetryRefresh) ...?existingExtraSensorData,
};
final incomingMetricFamilies = incomingExtraSensorData.keys
.map(_telemetryMetricFamilyForKey)
.whereType<String>()

View File

@@ -328,9 +328,16 @@ class _RecipientSelectorSheetState extends State<RecipientSelectorSheet> {
MessagesProvider? messagesProvider,
) {
final previewData = _channelPreviewData(context, channel, messagesProvider);
final sharingMode = context.watch<AppProvider>().channelLocationSharingModeForChannel(
channel.publicKey.length > 1 ? channel.publicKey[1] : 0,
);
ChannelLocationSharingMode? sharingMode;
try {
sharingMode = context
.watch<AppProvider>()
.channelLocationSharingModeForChannel(
channel.publicKey.length > 1 ? channel.publicKey[1] : 0,
);
} on ProviderNotFoundException {
sharingMode = null;
}
return _buildRecipientCard(
context: context,

View File

@@ -238,15 +238,27 @@ List<SensorMetricOption> sensorMetricOptionsFor(
final coreFieldKeys = <String>{
if (batteryMilliVolts != null || batteryPercentage != null)
...extraSensorData?.keys.where(
(k) => k.startsWith('voltage_') || k.startsWith('analog_input_'),
(k) =>
_isSourceChannelMetric(extraSensorData, 'voltage', k) ||
_isSourceChannelMetric(extraSensorData, 'battery', k) ||
k.startsWith('analog_input_'),
) ??
[],
if (temperature != null)
...extraSensorData?.keys.where((k) => k.startsWith('temperature_')) ?? [],
...extraSensorData?.keys.where(
(k) => _isSourceChannelMetric(extraSensorData, 'temperature', k),
) ??
[],
if (humidity != null)
...extraSensorData?.keys.where((k) => k.startsWith('humidity_')) ?? [],
...extraSensorData?.keys.where(
(k) => _isSourceChannelMetric(extraSensorData, 'humidity', k),
) ??
[],
if (pressure != null)
...extraSensorData?.keys.where((k) => k.startsWith('pressure_')) ?? [],
...extraSensorData?.keys.where(
(k) => _isSourceChannelMetric(extraSensorData, 'pressure', k),
) ??
[],
};
if (extraSensorData != null) {
@@ -3117,6 +3129,18 @@ int? _sourceChannelForField(
return null;
}
bool _isSourceChannelMetric(
Map<String, dynamic>? extraSensorData,
String fieldKey,
String metricKey,
) {
final sourceChannel = _sourceChannelForField(extraSensorData, fieldKey);
if (sourceChannel == null) {
return false;
}
return metricKey == '${fieldKey}_$sourceChannel';
}
String _resolvedMetricLabel(
String fieldKey,
String defaultLabel, {