1 import { createAction } from '@reduxjs/toolkit';
2 import { c } from 'ttag';
4 import { withCache } from '@proton/pass/store/actions/enhancers/cache';
5 import { withNotification } from '@proton/pass/store/actions/enhancers/notification';
6 import { trashEmptyRequest, trashRestoreRequest } from '@proton/pass/store/actions/requests';
12 } from '@proton/pass/store/request/enhancers';
13 import type { BatchItemRevisionIDs } from '@proton/pass/types';
14 import { pipe } from '@proton/pass/utils/fp/pipe';
16 export const emptyTrashIntent = createAction('trash::empty::intent', () =>
18 withRequest({ status: 'start', id: trashEmptyRequest() }),
21 text: c('Info').t`Emptying trash...`,
28 export const emptyTrashFailure = createAction(
29 'trash::empty::failure',
30 withRequestFailure((error: unknown) =>
33 text: c('Error').t`Emptying trash failed`,
35 })({ payload: {}, error })
39 export const emptyTrashProgress = createAction(
40 'trash::empty::progress',
41 withRequestProgress((payload: BatchItemRevisionIDs) => withCache({ payload }))
44 export const emptyTrashSuccess = createAction(
45 'trash::empty::success',
46 withRequestSuccess(() =>
50 text: c('Info').t`All trashed items permanently deleted`,
56 export const restoreTrashIntent = createAction('trash::restore::intent', () =>
58 withRequest({ status: 'start', id: trashRestoreRequest() }),
61 text: c('Info').t`Restoring trashed items...`,
68 export const restoreTrashFailure = createAction(
69 'trash::restore::failure',
70 withRequestFailure((error: unknown) =>
73 text: c('Error').t`Restoring trashed items failed`,
75 })({ payload: {}, error })
79 export const restoreTrashProgress = createAction(
80 'trash::restore::progress',
81 withRequestProgress((payload: BatchItemRevisionIDs) => withCache({ payload }))
84 export const restoreTrashSuccess = createAction(
85 'trash::restore::success',
86 withRequestSuccess(() =>
89 text: c('Info').t`All trashed items successfully restored`,