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[]) {
10 const drafts: Draft[] = yield select(selectItemDrafts);
11 const deleteDrafts = matchDraftsForShare(drafts, shareId, itemIds);
12 yield all(deleteDrafts.map((draft) => put(draftDiscard(draft))));