Update selected item color in Pass menu
[ProtonMail-WebClient.git] / packages / pass / store / sagas / items / item-drafts.ts
blob70ad8968be66f01302a81d3799e42bc4ae7985d1
1 import { all, put, select } from 'redux-saga/effects';
3 import { matchDraftsForShare } from '@proton/pass/lib/items/item.utils';
4 import { draftDiscard } from '@proton/pass/store/actions';
5 import type { Draft } from '@proton/pass/store/reducers';
6 import { selectItemDrafts } from '@proton/pass/store/selectors';
8 export function* discardDrafts(shareId: string, itemIds?: string[]) {
9     try {
10         const drafts: Draft[] = yield select(selectItemDrafts);
11         const deleteDrafts = matchDraftsForShare(drafts, shareId, itemIds);
12         yield all(deleteDrafts.map((draft) => put(draftDiscard(draft))));
13     } catch {}