1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-25 04:46:40 +07:00

fixed lab node creation bug

This commit is contained in:
Fedor Katurov 2021-09-22 10:07:14 +07:00
parent b7aae5eccd
commit e2a69b2b2e
3 changed files with 17 additions and 8 deletions

View file

@ -7,7 +7,7 @@ import { isAfter, parseISO } from 'date-fns';
interface IProps { interface IProps {
node: INode; node: INode;
lastSeen: string | null; lastSeen: string | null | undefined;
isLoading?: boolean; isLoading?: boolean;
commentCount: number; commentCount: number;
} }

View file

@ -25,7 +25,7 @@ export type GetLabNodesRequest = {
export interface ILabNode { export interface ILabNode {
node: INode; node: INode;
last_seen: string | null; last_seen: string | null | undefined;
comment_count: number; comment_count: number;
} }

View file

@ -50,6 +50,8 @@ import { Unwrap } from '../types';
import { NODE_EDITOR_DIALOGS } from '~/constants/dialogs'; import { NODE_EDITOR_DIALOGS } from '~/constants/dialogs';
import { DIALOGS } from '~/redux/modal/constants'; import { DIALOGS } from '~/redux/modal/constants';
import { has } from 'ramda'; import { has } from 'ramda';
import { selectLabListNodes } from '~/redux/lab/selectors';
import { labSetList } from '~/redux/lab/actions';
export function* updateNodeEverywhere(node) { export function* updateNodeEverywhere(node) {
const { const {
@ -80,12 +82,19 @@ function* onNodeSubmitLocal({ node, callback }: ReturnType<typeof nodeSubmitLoca
return; return;
} }
const nodes: ReturnType<typeof selectFlowNodes> = yield select(selectFlowNodes); if (node.is_promoted) {
const updated_flow_nodes = node.id const nodes: ReturnType<typeof selectFlowNodes> = yield select(selectFlowNodes);
? nodes.map(item => (item.id === result.id ? result : item)) const updated_flow_nodes = node.id
: [result, ...nodes]; ? nodes.map(item => (item.id === result.id ? result : item))
: [result, ...nodes];
yield put(flowSetNodes(updated_flow_nodes)); yield put(flowSetNodes(updated_flow_nodes));
} else {
const nodes: ReturnType<typeof selectLabListNodes> = yield select(selectLabListNodes);
const updated_lab_nodes = node.id
? nodes.map(item => (item.node.id === result.id ? { ...item, node: result } : item))
: [{ node: result, comment_count: 0, last_seen: node.created_at }, ...nodes];
yield put(labSetList({ nodes: updated_lab_nodes }));
}
const { current } = yield select(selectNode); const { current } = yield select(selectNode);