AkurAI Build
Menu

Public repository / 0216cf0f6008aae88a648a82e9b3a462a6688302

AkurAI-Mail / src/framework/signal-badge.js

Latest change 7a6a24a4e46f9f1d964c5593c076f9bdf638fea0 - Fix svelte-check errors in framework signal-badge and sync-state by Ólafur Búi Ólafsson

// View model for the conversation signal badge (framework island data; no DOM, no Svelte).
/** @type {Record<string, string>} */
const ICONS = { replyNeeded: "message-circle", followUpDue: "clock", priority: "flag" };

/** @param {string} type */
export function signalIconName(type) {
  return ICONS[type] ?? "bell";
}

/** @param {string} type @param {{value?: string}} [signal] */
export function signalLabel(type, signal) {
  if (type === "replyNeeded") return "Reply needed";
  if (type === "followUpDue") return "Follow-up";
  if (type === "priority") return signal?.value === "high" ? "High priority" : "Priority";
  return type;
}

/** @param {string} type @param {string} [value] */
export function signalColorClass(type, value) {
  if (type === "replyNeeded" && value) return "signal-amber";
  if (type === "followUpDue" && value) return "signal-blue";
  if (type === "priority" && value === "high") return "signal-red";
  return "signal-muted";
}

/** @param {{days: number, hours: number}} [age] */
export function unansweredAgeLabel(age) {
  if (!age) return "";
  return age.days > 0 ? `${age.days}d` : `${age.hours}h`;
}