mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-26 05:16:41 +07:00
moved history listen to sagas
This commit is contained in:
parent
e5be4c383e
commit
d7ed0cbe54
9 changed files with 107 additions and 61 deletions
23
src/redux/modal/sagas.ts
Normal file
23
src/redux/modal/sagas.ts
Normal file
|
@ -0,0 +1,23 @@
|
|||
import { takeEvery, put } from 'redux-saga/effects';
|
||||
import { LocationChangeAction, LOCATION_CHANGE } from 'connected-react-router';
|
||||
import { authOpenProfile, authRestorePassword } from '../auth/actions';
|
||||
|
||||
function* onPathChange({
|
||||
payload: {
|
||||
location: { pathname },
|
||||
},
|
||||
}: LocationChangeAction) {
|
||||
if (pathname.match(/^\/~([\wа-яА-Я]+)/)) {
|
||||
const [, username] = pathname.match(/^\/~([\wа-яА-Я]+)/);
|
||||
return yield put(authOpenProfile(username));
|
||||
}
|
||||
|
||||
if (pathname.match(/^\/restore\/([\w\-]+)/)) {
|
||||
const [, code] = pathname.match(/^\/restore\/([\w\-]+)/);
|
||||
return yield put(authRestorePassword(code));
|
||||
}
|
||||
}
|
||||
|
||||
export function* modalSaga() {
|
||||
yield takeEvery(LOCATION_CHANGE, onPathChange);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue