mirror of
https://github.com/Mail-0/Zero.git
synced 2026-06-30 07:46:15 +00:00
Introduced `useDelete` and `useMoveTo` hooks to centralize deletion and movement logic for emails and threads. These hooks improve code reusability, streamline background queue handling, and enhance folder-specific actions like moving to bin or spam.
24 lines
723 B
TypeScript
24 lines
723 B
TypeScript
import { backgroundQueueAtom } from '@/store/backgroundQueue';
|
|
import { useAtom } from 'jotai';
|
|
|
|
const useBackgroundQueue = () => {
|
|
const [backgroundQueue, setBackgroundQueue] = useAtom(backgroundQueueAtom);
|
|
|
|
return {
|
|
addToQueue: (threadId: string) =>
|
|
setBackgroundQueue({
|
|
type: 'add',
|
|
threadId: threadId.startsWith('thread:') ? threadId : `thread:${threadId}`,
|
|
}),
|
|
deleteFromQueue: (threadId: string) =>
|
|
setBackgroundQueue({
|
|
type: 'delete',
|
|
threadId: threadId.startsWith('thread:') ? threadId : `thread:${threadId}`,
|
|
}),
|
|
clearQueue: () => setBackgroundQueue({ type: 'clear' }),
|
|
queue: backgroundQueue,
|
|
};
|
|
};
|
|
|
|
export default useBackgroundQueue;
|