import type { TeamMessageSummary } from '../../utils/collabTeamSummaries';
import { formatRelativeTime } from '../../utils/formatRelativeTime';
// One-line last-message preview + unread pill + relative time for a collaboration-team row.
// Renders nothing until the team has at least one message, unless its thread could not be read.
export const TeamMessagePreview = ({ summary, now }: { summary?: TeamMessageSummary; now: number }) => {
if (summary?.unreadable) {
return Messages could not be loaded;
}
if (!summary || summary.timestamp === 0) return null;
return (
{/* AN UNREAD COUNT IS NOT A DANGER, so it does not wear the danger colour. This was
`destructive` - the red reserved for irreversible and harmful things, the same token as
Dissolve the team - on a pill that means "three people have written to you".
It is now the app's ONE count badge rather than a general-purpose Badge that happens to
hold a number. `ahr-count-badge` carries the circle, the size, the tabular figures and
the weight, so every count in the product is the same object and moving it moves them
all. A Badge here would drift the moment somebody restyled Badge for its other uses. */}
{summary.unread > 0 && (
{summary.unread}
)}
{summary.preview}
{formatRelativeTime(summary.timestamp, now)}
);
};
export default TeamMessagePreview;