import type React from "react"; import { WaypointMessage } from "@components/PageComponents/Messages/WaypointMessage.js"; import { useDevice } from "@core/providers/useDevice.js"; import type { AllMessageTypes } from "@core/stores/deviceStore.js"; import { Hashicon } from "@emeraldpay/hashicon-react"; import { CheckCircleIcon, EllipsisHorizontalCircleIcon, ExclamationCircleIcon } from "@heroicons/react/24/outline"; import type { Protobuf } from "@meshtastic/meshtasticjs"; export interface MessageProps { lastMsgSameUser: boolean; message: AllMessageTypes; sender?: Protobuf.NodeInfo; } export const Message = ({ lastMsgSameUser, message, sender }: MessageProps): JSX.Element => { const { setPeerInfoOpen, setActivePeer, connection } = useDevice(); const openPeer = (): void => { setActivePeer(message.from); setPeerInfoOpen(true); }; return lastMsgSameUser ? (
{message.state === "ack" ? ( ) : message.state === "waiting" ? ( ) : ( )} {"waypointID" in message ? ( ) : ( {message.data} )}
) : (
{sender?.user?.longName ?? "UNK"} {message.rxTime.toLocaleTimeString(undefined, { hour: "2-digit", minute: "2-digit" })}
{message.state === "ack" ? ( ) : message.state === "waiting" ? ( ) : ( )} {"waypointID" in message ? ( ) : ( {message.data} )}
); };