/** * rChats applet definitions — Unread Count. */ import type { AppletDefinition, AppletLiveData } from "../../shared/applet-types"; const unreadCount: AppletDefinition = { id: "unread-count", label: "Unread Count", icon: "💬", accentColor: "#0891b2", ports: [ { name: "channel-in", type: "string", direction: "input" }, { name: "unread-out", type: "number", direction: "output" }, ], renderCompact(data: AppletLiveData): string { const { snapshot } = data; const channel = (snapshot.channel as string) || "general"; const unread = (snapshot.unread as number) || 0; const badgeColor = unread > 0 ? "#ef4444" : "#334155"; return `
#${channel}
${unread}
unread messages
`; }, onInputReceived(portName, value, ctx) { if (portName === "channel-in" && typeof value === "string") { ctx.emitOutput("unread-out", 0); } }, }; export const chatsApplets: AppletDefinition[] = [unreadCount];