1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-26 05:16:41 +07:00

flow grid now has 5 columns

This commit is contained in:
Fedor Katurov 2019-10-23 14:51:34 +07:00
parent 744f79053b
commit ed3f6369fb
5 changed files with 34 additions and 11 deletions

View file

@ -1,10 +1,11 @@
import { takeLatest, call, put } from 'redux-saga/effects';
import { takeLatest, call, put, select } from 'redux-saga/effects';
import { REHYDRATE } from 'redux-persist';
import { FLOW_ACTIONS } from './constants';
import { getNodes } from '../node/api';
import { flowSetNodes } from './actions';
import { objFromArray } from '~/utils/fn';
import { flowSetNodes, flowSetCellView } from './actions';
import { IResultWithStatus, INode } from '../types';
import { updateNodeEverywhere } from '../node/sagas';
import { selectFlowNodes } from './selectors';
function* onGetFlow() {
const {
@ -20,6 +21,12 @@ function* onGetFlow() {
yield put(flowSetNodes(nodes));
}
function* onSetCellView({ id, flow }: ReturnType<typeof flowSetCellView>) {
const nodes = yield select(selectFlowNodes);
yield put(flowSetNodes(nodes.map(node => (node.id === id ? { ...node, flow } : node))));
}
export default function* nodeSaga() {
yield takeLatest([FLOW_ACTIONS.GET_FLOW, REHYDRATE], onGetFlow);
yield takeLatest(FLOW_ACTIONS.SET_CELL_VIEW, onSetCellView);
}

View file

@ -41,7 +41,7 @@ import { NODE_EDITOR_DIALOGS, DIALOGS } from '../modal/constants';
import { INodeState } from './reducer';
import { IFlowState } from '../flow/reducer';
function* updateNodeEverythere(node) {
export function* updateNodeEverywhere(node) {
const {
current: { id },
}: INodeState = yield select(selectNode);
@ -189,13 +189,13 @@ function* onLikeSaga({ id }: ReturnType<typeof nodeLike>) {
current: { is_liked },
} = yield select(selectNode);
yield call(updateNodeEverythere, { ...current, is_liked: !is_liked });
yield call(updateNodeEverywhere, { ...current, is_liked: !is_liked });
const { data, error } = yield call(reqWrapper, postNodeLike, { id });
if (!error || data.is_liked === !is_liked) return; // ok and matches
yield call(updateNodeEverythere, { ...current, is_liked });
yield call(updateNodeEverywhere, { ...current, is_liked });
}
function* onStarSaga({ id }: ReturnType<typeof nodeLike>) {
@ -204,13 +204,13 @@ function* onStarSaga({ id }: ReturnType<typeof nodeLike>) {
current: { is_heroic },
} = yield select(selectNode);
yield call(updateNodeEverythere, { ...current, is_heroic: !is_heroic });
yield call(updateNodeEverywhere, { ...current, is_heroic: !is_heroic });
const { data, error } = yield call(reqWrapper, postNodeStar, { id });
if (!error || data.is_heroic === !is_heroic) return; // ok and matches
yield call(updateNodeEverythere, { ...current, is_heroic });
yield call(updateNodeEverywhere, { ...current, is_heroic });
}
export default function* nodeSaga() {