mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-07-11 11:07:04 +10:00
upd - fix and format
This commit is contained in:
@@ -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 = [
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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}) {
|
||||
|
||||
Reference in New Issue
Block a user