mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-26 05:16:41 +07:00
added updated nodes to flow
This commit is contained in:
parent
6f76bec2c0
commit
74cd181530
13 changed files with 128 additions and 30 deletions
|
@ -17,6 +17,11 @@ export const flowSetRecent = (recent: IFlowState['recent']) => ({
|
|||
type: FLOW_ACTIONS.SET_RECENT,
|
||||
});
|
||||
|
||||
export const flowSetUpdated = (updated: IFlowState['updated']) => ({
|
||||
updated,
|
||||
type: FLOW_ACTIONS.SET_UPDATED,
|
||||
});
|
||||
|
||||
export const flowSetCellView = (id: INode['id'], flow: INode['flow']) => ({
|
||||
type: FLOW_ACTIONS.SET_CELL_VIEW,
|
||||
id,
|
||||
|
|
|
@ -5,5 +5,6 @@ export const FLOW_ACTIONS = {
|
|||
SET_NODES: `${prefix}SET_NODES`,
|
||||
SET_HEROES: `${prefix}SET_HEROES`,
|
||||
SET_RECENT: `${prefix}SET_RECENT`,
|
||||
SET_UPDATED: `${prefix}SET_UPDATED`,
|
||||
SET_CELL_VIEW: `${prefix}SET_CELL_VIEW`,
|
||||
};
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import assocPath from 'ramda/es/assocPath';
|
||||
import { FLOW_ACTIONS } from './constants';
|
||||
import { flowSetNodes, flowSetHeroes, flowSetRecent } from './actions';
|
||||
import { flowSetNodes, flowSetHeroes, flowSetRecent, flowSetUpdated } from './actions';
|
||||
import { IFlowState } from './reducer';
|
||||
|
||||
const setNodes = (state: IFlowState, { nodes }: ReturnType<typeof flowSetNodes>) =>
|
||||
|
@ -12,8 +12,12 @@ const setHeroes = (state: IFlowState, { heroes }: ReturnType<typeof flowSetHeroe
|
|||
const setRecent = (state: IFlowState, { recent }: ReturnType<typeof flowSetRecent>) =>
|
||||
assocPath(['recent'], recent, state);
|
||||
|
||||
const setUpdated = (state: IFlowState, { updated }: ReturnType<typeof flowSetUpdated>) =>
|
||||
assocPath(['updated'], updated, state);
|
||||
|
||||
export const FLOW_HANDLERS = {
|
||||
[FLOW_ACTIONS.SET_NODES]: setNodes,
|
||||
[FLOW_ACTIONS.SET_HEROES]: setHeroes,
|
||||
[FLOW_ACTIONS.SET_RECENT]: setRecent,
|
||||
[FLOW_ACTIONS.SET_UPDATED]: setUpdated,
|
||||
};
|
||||
|
|
|
@ -7,6 +7,7 @@ export type IFlowState = Readonly<{
|
|||
nodes: INode[];
|
||||
heroes: Partial<INode>[];
|
||||
recent: Partial<INode>[];
|
||||
updated: Partial<INode>[];
|
||||
error: IError;
|
||||
}>;
|
||||
|
||||
|
@ -14,6 +15,7 @@ const INITIAL_STATE: IFlowState = {
|
|||
nodes: [],
|
||||
heroes: [],
|
||||
recent: [],
|
||||
updated: [],
|
||||
is_loading: false,
|
||||
error: null,
|
||||
};
|
||||
|
|
|
@ -2,7 +2,13 @@ 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, flowSetCellView, flowSetHeroes, flowSetRecent } from './actions';
|
||||
import {
|
||||
flowSetNodes,
|
||||
flowSetCellView,
|
||||
flowSetHeroes,
|
||||
flowSetRecent,
|
||||
flowSetUpdated,
|
||||
} from './actions';
|
||||
import { IResultWithStatus, INode } from '../types';
|
||||
import { selectFlowNodes } from './selectors';
|
||||
import { reqWrapper } from '../auth/sagas';
|
||||
|
@ -11,23 +17,26 @@ import { IFlowState } from './reducer';
|
|||
|
||||
function* onGetFlow() {
|
||||
const {
|
||||
data: { nodes = null, heroes = null, recent = null },
|
||||
data: { nodes = null, heroes = null, recent = [], updated = [] },
|
||||
}: IResultWithStatus<{
|
||||
nodes: IFlowState['nodes'];
|
||||
heroes: IFlowState['heroes'];
|
||||
recent: IFlowState['recent'];
|
||||
}> = yield call(getNodes, {});
|
||||
updated: IFlowState['updated'];
|
||||
}> = yield call(reqWrapper, getNodes, {});
|
||||
|
||||
if (!nodes || !nodes.length) {
|
||||
yield put(flowSetNodes([]));
|
||||
yield put(flowSetHeroes([]));
|
||||
yield put(flowSetRecent([]));
|
||||
yield put(flowSetUpdated([]));
|
||||
return;
|
||||
}
|
||||
|
||||
yield put(flowSetNodes(nodes));
|
||||
yield put(flowSetHeroes(heroes));
|
||||
yield put(flowSetRecent(recent));
|
||||
yield put(flowSetUpdated(updated));
|
||||
}
|
||||
|
||||
function* onSetCellView({ id, flow }: ReturnType<typeof flowSetCellView>) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue