fix wrong hop count in channel_message_path_screen observed path chooser.

This commit is contained in:
ericz
2026-05-18 22:49:56 +02:00
parent 91759f531a
commit 3f1bd54889
+25 -17
View File
@@ -490,11 +490,17 @@ class _ChannelMessagePathMapScreenState
? Uint8List.fromList(selectedPathTmp.reversed.toList()) ? Uint8List.fromList(selectedPathTmp.reversed.toList())
: selectedPathTmp; : selectedPathTmp;
final selectedIndex = _indexForPath(selectedPath, observedPaths); final width =
final width = (widget.message.pathHashWidth ?? connector.pathHashByteWidth) (widget.message.pathHashWidth ?? connector.pathHashByteWidth)
.clamp(1, 4) .clamp(1, 4)
.toInt(); .toInt();
final hops = _buildPathHops(selectedPath, connector, context.l10n, width); final selectedIndex = _indexForPath(selectedPathTmp, observedPaths);
final hops = _buildPathHops(
selectedPath,
connector,
context.l10n,
width,
);
final points = <LatLng>[]; final points = <LatLng>[];
@@ -612,14 +618,18 @@ class _ChannelMessagePathMapScreenState
bounds: bounds, bounds: bounds,
), ),
if (observedPaths.length > 1) if (observedPaths.length > 1)
_buildPathSelector(context, observedPaths, selectedIndex, ( _buildPathSelector(
index, context,
) { observedPaths,
setState(() { selectedIndex,
_selectedPath = observedPaths[index].pathBytes; width,
_focusedHopIndex = null; (index) {
}); setState(() {
}), _selectedPath = observedPaths[index].pathBytes;
_focusedHopIndex = null;
});
},
),
if (points.isEmpty) if (points.isEmpty)
Center( Center(
child: Card( child: Card(
@@ -645,13 +655,11 @@ class _ChannelMessagePathMapScreenState
BuildContext context, BuildContext context,
List<_ObservedPath> paths, List<_ObservedPath> paths,
int selectedIndex, int selectedIndex,
int hashByteWidth,
ValueChanged<int> onSelected, ValueChanged<int> onSelected,
) { ) {
final l10n = context.l10n; final l10n = context.l10n;
final width = context.read<MeshCoreConnector>().pathHashByteWidth.clamp( final width = hashByteWidth.clamp(1, 4);
1,
4,
);
final selectedPath = paths[selectedIndex]; final selectedPath = paths[selectedIndex];
final label = selectedPath.isPrimary final label = selectedPath.isPrimary
? l10n.channelPath_primaryPath(selectedIndex + 1) ? l10n.channelPath_primaryPath(selectedIndex + 1)