mirror of
https://github.com/plankanban/planka.git
synced 2025-07-19 13:19:44 +02:00
Initial commit
This commit is contained in:
commit
36fe34e8e1
583 changed files with 91539 additions and 0 deletions
71
client/src/sagas/app/services/router.js
Normal file
71
client/src/sagas/app/services/router.js
Normal file
|
@ -0,0 +1,71 @@
|
|||
import { call, put, select } from 'redux-saga/effects';
|
||||
import { push } from 'connected-react-router';
|
||||
|
||||
import { deleteNotificationsInCurrentCardService } from './notifications';
|
||||
import { fetchBoardRequest } from '../requests';
|
||||
import {
|
||||
currentBoardSelector,
|
||||
isAppInitializingSelector,
|
||||
pathsMatchSelector,
|
||||
} from '../../../selectors';
|
||||
import Paths from '../../../constants/Paths';
|
||||
|
||||
export function* goToRootService() {
|
||||
yield put(push(Paths.ROOT));
|
||||
}
|
||||
|
||||
export function* goToProjectService(projectId) {
|
||||
yield put(push(Paths.PROJECTS.replace(':id', projectId)));
|
||||
}
|
||||
|
||||
export function* goToBoardService(boardId) {
|
||||
yield put(push(Paths.BOARDS.replace(':id', boardId)));
|
||||
}
|
||||
|
||||
export function* goToCardService(cardId) {
|
||||
yield put(push(Paths.CARDS.replace(':id', cardId)));
|
||||
}
|
||||
|
||||
export function* runPathActionsService(pathsMatch) {
|
||||
if (!pathsMatch) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (pathsMatch.path) {
|
||||
case Paths.BOARDS:
|
||||
case Paths.CARDS: {
|
||||
const currentBoard = yield select(currentBoardSelector);
|
||||
|
||||
if (currentBoard && currentBoard.isFetching === null) {
|
||||
yield call(fetchBoardRequest, currentBoard.id);
|
||||
}
|
||||
|
||||
if (pathsMatch.path === Paths.CARDS) {
|
||||
yield call(deleteNotificationsInCurrentCardService);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
export function* locationChangedService() {
|
||||
const pathsMatch = yield select(pathsMatchSelector);
|
||||
|
||||
if (pathsMatch) {
|
||||
switch (pathsMatch.path) {
|
||||
case Paths.LOGIN:
|
||||
yield call(goToRootService);
|
||||
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
const isAppInitializing = yield select(isAppInitializingSelector);
|
||||
|
||||
if (!isAppInitializing) {
|
||||
yield call(runPathActionsService, pathsMatch);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue