mirror of
https://github.com/MarekWo/mc-webui.git
synced 2026-05-06 13:32:39 +02:00
fix(ui): fix leading pipe separator when SNR is missing from message
Use array-based metaParts.join(' | ') instead of string concatenation
to avoid ugly leading "| Hops: 0" when meshcore lib doesn't provide SNR.
Also revert temporary INFO-level debug logging back to DEBUG.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -228,7 +228,7 @@ class DeviceManager:
|
||||
for event_type, handler in handlers:
|
||||
sub = self.mc.subscribe(event_type, handler)
|
||||
self._subscriptions.append(sub)
|
||||
logger.info(f"Subscribed to {event_type.value}")
|
||||
logger.debug(f"Subscribed to {event_type.value}")
|
||||
|
||||
def _sync_contacts_to_db(self):
|
||||
"""Sync device contacts to database."""
|
||||
@@ -519,7 +519,7 @@ class DeviceManager:
|
||||
import io
|
||||
data = getattr(event, 'payload', {})
|
||||
payload_hex = data.get('payload', '')
|
||||
logger.info(f"RX_LOG_DATA received: {len(payload_hex)//2} bytes, snr={data.get('snr')}")
|
||||
logger.debug(f"RX_LOG_DATA received: {len(payload_hex)//2} bytes, snr={data.get('snr')}")
|
||||
if not payload_hex:
|
||||
return
|
||||
|
||||
|
||||
@@ -774,12 +774,12 @@ function createMessageElement(msg) {
|
||||
}));
|
||||
}
|
||||
|
||||
let metaInfo = '';
|
||||
let metaParts = [];
|
||||
if (msg.snr !== undefined && msg.snr !== null) {
|
||||
metaInfo += `SNR: ${msg.snr.toFixed(1)} dB`;
|
||||
metaParts.push(`SNR: ${msg.snr.toFixed(1)} dB`);
|
||||
}
|
||||
if (msg.path_len !== undefined && msg.path_len !== null) {
|
||||
metaInfo += ` | Hops: ${msg.path_len}`;
|
||||
metaParts.push(`Hops: ${msg.path_len}`);
|
||||
}
|
||||
if (msg.paths && msg.paths.length > 0) {
|
||||
// Show first path inline (shortest/first arrival)
|
||||
@@ -790,8 +790,9 @@ function createMessageElement(msg) {
|
||||
: segments.join('\u2192');
|
||||
const pathsData = encodeURIComponent(JSON.stringify(msg.paths));
|
||||
const routeLabel = msg.paths.length > 1 ? `Route (${msg.paths.length})` : 'Route';
|
||||
metaInfo += ` | <span class="path-info" onclick="showPathsPopup(this, '${pathsData}')">${routeLabel}: ${shortPath}</span>`;
|
||||
metaParts.push(`<span class="path-info" onclick="showPathsPopup(this, '${pathsData}')">${routeLabel}: ${shortPath}</span>`);
|
||||
}
|
||||
const metaInfo = metaParts.join(' | ');
|
||||
|
||||
if (msg.is_own) {
|
||||
// Own messages: right-aligned, no avatar
|
||||
|
||||
Reference in New Issue
Block a user