upd - fix and format

This commit is contained in:
HDDen
2026-06-14 01:36:49 +03:00
parent d61eaaaff1
commit e92d215582
7 changed files with 32 additions and 18 deletions
+16 -3
View File
@@ -515,6 +515,11 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
final displayPathHashWidth =
message.pathHashWidth ??
context.read<MeshCoreConnector>().pathHashByteWidth;
final displayHopCount = _displayHopCount(
displayPath,
displayPathHashWidth,
message.pathLength,
);
// Bubble colors — outgoing uses MeshPalette.me / meBorder / meInk.
final bubbleColor = isOutgoing
@@ -665,9 +670,7 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
children: [
RouteChip(
isDirect: (message.pathLength ?? -1) >= 0,
hops: (message.pathLength ?? -1) >= 0
? message.pathLength
: null,
hops: displayHopCount,
),
const SizedBox(width: 4),
Text(
@@ -1564,6 +1567,16 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
).map(PathHelper.formatHopHex).join(',');
}
int? _displayHopCount(
Uint8List pathBytes,
int pathHashByteWidth,
int? fallbackPathLength,
) {
if ((fallbackPathLength ?? -1) < 0) return null;
if (pathBytes.isEmpty) return fallbackPathLength;
return PathHelper.splitPathBytes(pathBytes, pathHashByteWidth).length;
}
/// Deterministic name-to-hue mapping consistent with [AvatarCircle].
Color _colorForName(String name) {
const hues = [
+4 -6
View File
@@ -156,11 +156,11 @@ class ChannelMessagePathScreen extends StatelessWidget {
}) {
final l10n = context.l10n;
final scheme = Theme.of(context).colorScheme;
final routeChip = message.pathLength == null
final routeChip = effectiveHopCount == null
? null
: message.pathLength! < 0
: effectiveHopCount < 0
? const RouteChip(isDirect: false)
: RouteChip(isDirect: true, hops: message.pathLength);
: RouteChip(isDirect: true, hops: effectiveHopCount);
return MeshCard(
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
@@ -1887,9 +1887,7 @@ Uint8List _orientPathBytes(
}) {
if (!reverse || pathBytes.isEmpty) return pathBytes;
final hops = PathHelper.splitPathBytes(pathBytes, hashByteWidth);
return Uint8List.fromList([
for (final hop in hops.reversed) ...hop,
]);
return Uint8List.fromList([for (final hop in hops.reversed) ...hop]);
}
int _hopCountFromBytes(int byteCount, int hashByteWidth) {
+3 -1
View File
@@ -1321,7 +1321,9 @@ class _MapScreenState extends State<MapScreen> {
(contact.type == advTypeRepeater || contact.type == advTypeRoom) &&
contact.publicKey.length >= overlapHopWidth &&
overlapPrefixes.contains(
PathHelper.formatHopHex(contact.publicKey.sublist(0, overlapHopWidth)),
PathHelper.formatHopHex(
contact.publicKey.sublist(0, overlapHopWidth),
),
);
void addNode(Contact contact, {bool dot = false}) {