1 import { put, takeEvery } from 'redux-saga/effects';
3 import { moveItem } from '@proton/pass/lib/items/item.requests';
4 import { itemMoveFailure, itemMoveIntent, itemMoveSuccess } from '@proton/pass/store/actions';
5 import type { ItemRevision } from '@proton/pass/types';
7 function* itemCreationWorker({ payload }: ReturnType<typeof itemMoveIntent>) {
8 const { item: itemToMove, optimisticId, shareId } = payload;
11 const item: ItemRevision = yield moveItem(itemToMove, itemToMove.shareId, shareId);
12 yield put(itemMoveSuccess({ item, optimisticId, shareId }));
13 } catch (e: unknown) {
14 yield put(itemMoveFailure({ optimisticId, shareId, item: itemToMove }, e));
18 export default function* watcher() {
19 yield takeEvery(itemMoveIntent.match, itemCreationWorker);