1 import { put, takeEvery } from 'redux-saga/effects';
3 import { api } from '@proton/pass/lib/api/api';
4 import { createTelemetryEvent } from '@proton/pass/lib/telemetry/event';
5 import { itemDeleteFailure, itemDeleteIntent, itemDeleteSuccess } from '@proton/pass/store/actions';
6 import type { RootSagaOptions } from '@proton/pass/store/types';
7 import { TelemetryEventName, TelemetryItemType } from '@proton/pass/types/data/telemetry';
10 { onItemsUpdated, getTelemetry }: RootSagaOptions,
11 { payload }: ReturnType<typeof itemDeleteIntent>
13 const telemetry = getTelemetry();
14 const { item, shareId } = payload;
18 url: `pass/v1/share/${payload.shareId}/item`,
24 Revision: item.revision,
30 void telemetry?.push(createTelemetryEvent(TelemetryEventName.ItemDeletion, {}, { type: TelemetryItemType[item.data.type] }));
31 yield put(itemDeleteSuccess({ itemId: item.itemId, shareId }));
34 yield put(itemDeleteFailure({ itemId: item.itemId, shareId }, e));
38 export default function* watcher(options: RootSagaOptions) {
39 yield takeEvery(itemDeleteIntent.match, deleteItem, options);