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

added updates everywhere

This commit is contained in:
Fedor Katurov 2021-04-02 17:49:03 +07:00
parent a451e30499
commit b1e68a8a6d
27 changed files with 246 additions and 79 deletions

View file

@ -2,6 +2,10 @@ import { FLOW_ACTIONS } from './constants';
import { IFlowState } from './reducer';
import { INode } from '../types';
export const flowGetFlow = () => ({
type: FLOW_ACTIONS.GET_FLOW,
});
export const flowSetNodes = (nodes: IFlowState['nodes']) => ({
nodes,
type: FLOW_ACTIONS.SET_NODES,
@ -50,3 +54,8 @@ export const flowChangeSearch = (search: Partial<IFlowState['search']>) => ({
export const flowLoadMoreSearch = () => ({
type: FLOW_ACTIONS.LOAD_MORE_SEARCH,
});
export const flowSeenNode = (nodeId: INode['id']) => ({
type: FLOW_ACTIONS.SEEN_NODE,
nodeId,
});

View file

@ -14,4 +14,6 @@ export const FLOW_ACTIONS = {
SET_SEARCH: `${prefix}SET_SEARCH`,
CHANGE_SEARCH: `${prefix}CHANGE_SEARCH`,
LOAD_MORE_SEARCH: `${prefix}LOAD_MORE_SEARCH`,
SEEN_NODE: `${prefix}SEEN_NODE`,
};

View file

@ -16,6 +16,8 @@ import { Unwrap } from '../types';
import { selectFlow, selectFlowNodes } from './selectors';
import { getSearchResults, postCellView } from './api';
import { uniq } from 'ramda';
import { labSeenNode, labSetUpdates } from '~/redux/lab/actions';
import { selectLabUpdatesNodes } from '~/redux/lab/selectors';
function hideLoader() {
const loader = document.getElementById('main_loader');
@ -185,10 +187,16 @@ function* loadMoreSearch() {
}
}
function* seenNode({ nodeId }: ReturnType<typeof labSeenNode>) {
const { updated }: ReturnType<typeof selectFlow> = yield select(selectFlow);
yield put(flowSetUpdated(updated.filter(node => node.id != nodeId)));
}
export default function* nodeSaga() {
yield takeLatest([FLOW_ACTIONS.GET_FLOW, REHYDRATE], onGetFlow);
yield takeLatest(FLOW_ACTIONS.SET_CELL_VIEW, onSetCellView);
yield takeLeading(FLOW_ACTIONS.GET_MORE, getMore);
yield takeLatest(FLOW_ACTIONS.CHANGE_SEARCH, changeSearch);
yield takeLatest(FLOW_ACTIONS.LOAD_MORE_SEARCH, loadMoreSearch);
yield takeLatest(FLOW_ACTIONS.SEEN_NODE, seenNode);
}

View file

@ -3,3 +3,4 @@ import { IFlowState } from './reducer';
export const selectFlow = (state: IState): IFlowState => state.flow;
export const selectFlowNodes = (state: IState) => state.flow.nodes;
export const selectFlowUpdated = (state: IState) => state.flow.updated;