diff --git a/src/components/ChatMessageItem.tsx b/src/components/ChatMessageItem.tsx index 81b4422..457583a 100644 --- a/src/components/ChatMessageItem.tsx +++ b/src/components/ChatMessageItem.tsx @@ -7,12 +7,12 @@ export interface ChatMessage { ingest_timestamp: string; origins: string[]; mesh_timestamp: string; - packet: string; path_len: number; - path: string; channel_hash: string; mac: string; encrypted_message: string; + message_count: number; + origin_path_array: Array<[string, string]>; // Array of [origin, path] tuples } function formatHex(hex: string): string { @@ -64,14 +64,14 @@ export default function ChatMessageItem({ msg, showErrorRow }: { msg: ChatMessag return () => { cancelled = true; }; }, [msg.encrypted_message, msg.mac, msg.channel_hash, knownKeys.join(",")]); - const origins = msg.origins && msg.origins.length > 0 ? msg.origins : []; - const originsCount = origins.length; + const originPathArray = msg.origin_path_array && msg.origin_path_array.length > 0 ? msg.origin_path_array : []; + const originsCount = originPathArray.length; const OriginsBox = () => ( -
+
{originsExpanded && originsCount > 0 && ( -
- {origins.map((origin, index) => ( -
- {origin} -
- ))} +
+ {originPathArray.map(([origin, path], index) => { + // Parse path into 2-character slices + const pathSlices = path.match(/.{1,2}/g) || []; + const formattedPath = pathSlices.join(' '); + + return ( +
+ {origin} + {formattedPath} +
+ ); + })}
)}
diff --git a/src/lib/clickhouse/actions.ts b/src/lib/clickhouse/actions.ts index e579712..e843d49 100644 --- a/src/lib/clickhouse/actions.ts +++ b/src/lib/clickhouse/actions.ts @@ -67,7 +67,7 @@ export async function getLatestChatMessages({ limit = 20, before, after, channel params.channelId = channelId; } const whereClause = where.length > 0 ? `WHERE ${where.join(' AND ')}` : ''; - const query = `SELECT ingest_timestamp, origins, mesh_timestamp, path_len, path, channel_hash, mac, hex(encrypted_message) AS encrypted_message FROM meshcore_public_channel_messages ${whereClause} ORDER BY ingest_timestamp DESC LIMIT {limit:UInt32}`; + const query = `SELECT ingest_timestamp, origins, mesh_timestamp, path_len, channel_hash, mac, hex(encrypted_message) AS encrypted_message, message_count, origin_path_array FROM meshcore_public_channel_messages ${whereClause} ORDER BY ingest_timestamp DESC LIMIT {limit:UInt32}`; const resultSet = await clickhouse.query({ query, query_params: params, format: 'JSONEachRow' }); const rows = await resultSet.json(); return rows as Array<{ @@ -75,10 +75,11 @@ export async function getLatestChatMessages({ limit = 20, before, after, channel origins: string[]; mesh_timestamp: string; path_len: number; - path: string; channel_hash: string; mac: string; encrypted_message: string; + message_count: number; + origin_path_array: Array<[string, string]>; // Array of [origin, path] tuples }>; } catch (error) { console.error('ClickHouse error in getLatestChatMessages:', error);