Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

1.0 KB
Raw Blame
import { isMobileWidth } from '@core/mobile/mobileWidth';
import type { NotificationStack } from '@notifications';
import type { Notification } from '../types/notification';
import { formatRelativeTimestamp } from '../utils/timestamp';

interface NotificationTimestampProps {
  notification?: Notification;
  stack?: NotificationStack;
}

/**
 * Displays the timestamp of a notification
 * For single notifications, shows that notification's timestamp
 * For stacks, shows the most recent notification's timestamp
 */
export function NotificationTimestamp(props: NotificationTimestampProps) {
  const timestamp = () => {
    if (props.notification) {
      return props.notification.created_at;
    }
    if (props.stack && props.stack.notifications.length > 0) {
      return props.stack.notifications[0].created_at;
    }
    return undefined;
  };

  const formattedTimestamp = () => {
    const ts = timestamp();
    return ts
      ? formatRelativeTimestamp(ts, { condensed: isMobileWidth() })
      : '';
  };

  return <>{formattedTimestamp()}</>;
}