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:
parent
b7aae5eccd
commit
e2a69b2b2e
3 changed files with 17 additions and 8 deletions
|
@ -7,7 +7,7 @@ import { isAfter, parseISO } from 'date-fns';
|
|||
|
||||
interface IProps {
|
||||
node: INode;
|
||||
lastSeen: string | null;
|
||||
lastSeen: string | null | undefined;
|
||||
isLoading?: boolean;
|
||||
commentCount: number;
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ export type GetLabNodesRequest = {
|
|||
|
||||
export interface ILabNode {
|
||||
node: INode;
|
||||
last_seen: string | null;
|
||||
last_seen: string | null | undefined;
|
||||
comment_count: number;
|
||||
}
|
||||
|
||||
|
|
|
@ -50,6 +50,8 @@ import { Unwrap } from '../types';
|
|||
import { NODE_EDITOR_DIALOGS } from '~/constants/dialogs';
|
||||
import { DIALOGS } from '~/redux/modal/constants';
|
||||
import { has } from 'ramda';
|
||||
import { selectLabListNodes } from '~/redux/lab/selectors';
|
||||
import { labSetList } from '~/redux/lab/actions';
|
||||
|
||||
export function* updateNodeEverywhere(node) {
|
||||
const {
|
||||
|
@ -80,12 +82,19 @@ function* onNodeSubmitLocal({ node, callback }: ReturnType<typeof nodeSubmitLoca
|
|||
return;
|
||||
}
|
||||
|
||||
if (node.is_promoted) {
|
||||
const nodes: ReturnType<typeof selectFlowNodes> = yield select(selectFlowNodes);
|
||||
const updated_flow_nodes = node.id
|
||||
? nodes.map(item => (item.id === result.id ? result : item))
|
||||
: [result, ...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);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue