1 import { fork, takeLeading } from 'redux-saga/effects';
3 import { LockMode } from '@proton/pass/lib/auth/lock/types';
4 import { lock } from '@proton/pass/store/actions';
5 import type { RootSagaOptions } from '@proton/pass/store/types';
6 import noop from '@proton/utils/noop';
8 /* If we the user has not registered a lock yet (ie: has
9 * a sessionLockToken saved) then this saga should have
10 * no effect. Fork the effect for non-blocking action -> immediate UI effect */
11 function* lockWorker({ getAuthService, getAuthStore: getAuth }: RootSagaOptions) {
12 const mode = getAuth().getLockMode();
14 if (mode !== LockMode.NONE) {
15 yield fork(function* () {
16 yield getAuthService().lock(mode, { soft: false }).catch(noop);
21 export default function* watcher(options: RootSagaOptions) {
22 yield takeLeading(lock.match, lockWorker, options);