Update selected item color in Pass menu
[ProtonMail-WebClient.git] / packages / pass / store / sagas / alias / alias-options-request.saga.ts
blob22134684416ad3b6eb4158608f67b83ab7f1f490
1 import { put, takeEvery } from 'redux-saga/effects';
3 import { getAliasOptions } from '@proton/pass/lib/alias/alias.requests';
4 import { getAliasOptionsFailure, getAliasOptionsIntent, getAliasOptionsSuccess } from '@proton/pass/store/actions';
5 import type { AliasOptions } from '@proton/pass/types';
7 function* requestAliasOptions(action: ReturnType<typeof getAliasOptionsIntent>) {
8     const {
9         payload: { shareId },
10         meta: { callback: onAliasOptionsIntentProcessed, request },
11     } = action;
13     try {
14         const options: AliasOptions = yield getAliasOptions(shareId);
15         const aliasOptionsSuccessAction = getAliasOptionsSuccess(request.id, { options });
16         yield put(aliasOptionsSuccessAction);
17         onAliasOptionsIntentProcessed?.(aliasOptionsSuccessAction);
18     } catch (e) {
19         const aliasOptionsFailureAction = getAliasOptionsFailure(request.id, e);
20         yield put(aliasOptionsFailureAction);
21         onAliasOptionsIntentProcessed?.(aliasOptionsFailureAction);
22     }
25 export default function* watcher() {
26     yield takeEvery(getAliasOptionsIntent.match, requestAliasOptions);