1 import { c } from 'ttag';
3 import Toggle from '@proton/components/components/toggle/Toggle';
4 import useApi from '@proton/components/hooks/useApi';
5 import useEventManager from '@proton/components/hooks/useEventManager';
6 import useNotifications from '@proton/components/hooks/useNotifications';
7 import useToggle from '@proton/components/hooks/useToggle';
8 import { useLoading } from '@proton/hooks';
9 import { updateShowAlmostAllMail } from '@proton/shared/lib/api/mailSettings';
13 showAlmostAllMail: number;
16 const AlmostAllMailToggle = ({ id, showAlmostAllMail }: Props) => {
17 const { createNotification } = useNotifications();
18 const [loading, withLoading] = useLoading();
19 const { call } = useEventManager();
21 const { state, toggle } = useToggle(Boolean(showAlmostAllMail));
23 const handleChange = async (checked: boolean) => {
25 await api(updateShowAlmostAllMail(bit));
28 createNotification({ text: c('Success').t`Preference saved` });
35 onChange={({ target }) => withLoading(handleChange(target.checked))}
41 export default AlmostAllMailToggle;