π€― LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
import { Button, toast } from '@lobehub/ui';
import { CheckCheckIcon } from 'lucide-react';
import { memo, useCallback, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { type BriefItem } from '@/features/DailyBrief/types';
import { useBriefStore } from '@/store/brief';
interface MarkAllReadButtonProps {
news: BriefItem[];
/** Fired after the resolve lands β lets the day digest revalidate its own SWR cache. */
onResolved?: () => void;
}
/**
* Clears the whole news pile in one click. Resolution happens with the neutral
* `read` action β reports are knowledge, so dismissing them wholesale must
* never accept a delivery or complete a task.
*/
const MarkAllReadButton = memo<MarkAllReadButtonProps>(({ news, onResolved }) => {
const { t } = useTranslation('home');
const resolveBriefsAsRead = useBriefStore((s) => s.resolveBriefsAsRead);
const [loading, setLoading] = useState(false);
const handleClick = useCallback(async () => {
setLoading(true);
try {
await resolveBriefsAsRead(news.map((brief) => brief.id));
onResolved?.();
} catch (error) {
// Without this the button just stops spinning and the pile stays put β
// the tRPC client only console.errors non-401 failures.
toast.error((error as Error)?.message || t('brief.actionFailed'));
} finally {
setLoading(false);
}
}, [news, onResolved, resolveBriefsAsRead, t]);
return (
<Button
disabled={loading}
icon={CheckCheckIcon}
size={'small'}
type={'text'}
onClick={handleClick}
>
{t('inbox.news.markAllRead')}
</Button>
);
});
export default MarkAllReadButton;