From fbd64dec4ce0a7a08d3bb535dd92d5e82c41f100 Mon Sep 17 00:00:00 2001 From: Fedor Katurov Date: Tue, 22 Oct 2019 13:01:31 +0700 Subject: [PATCH] posting node updates flow --- src/constants/errors.ts | 2 ++ src/redux/node/sagas.ts | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/constants/errors.ts b/src/constants/errors.ts index 92aea57b..efcb7ca1 100644 --- a/src/constants/errors.ts +++ b/src/constants/errors.ts @@ -8,6 +8,7 @@ export const ERRORS = { UNKNOWN_NODE_TYPE: 'Unknown_Node_Type', URL_INVALID: 'Url_Invalid', FILES_AUDIO_REQUIRED: 'Files_Audio_Required', + NOT_ENOUGH_RIGHTS: 'Not_Enough_Rights', }; export const ERROR_LITERAL = { @@ -20,4 +21,5 @@ export const ERROR_LITERAL = { [ERRORS.UNKNOWN_NODE_TYPE]: 'Неизвестный тип поста', [ERRORS.URL_INVALID]: 'Неизвестный адрес', [ERRORS.FILES_AUDIO_REQUIRED]: 'Нужна хотя бы одна песня', + [ERRORS.NOT_ENOUGH_RIGHTS]: 'У вас недостаточно прав', }; diff --git a/src/redux/node/sagas.ts b/src/redux/node/sagas.ts index aa6525c1..7200a9d8 100644 --- a/src/redux/node/sagas.ts +++ b/src/redux/node/sagas.ts @@ -46,7 +46,18 @@ function* onNodeSave({ node }: ReturnType) { } const nodes = yield select(selectFlowNodes); - yield put(flowSetNodes([result, ...nodes])); + const updated_flow_nodes = node.id + ? nodes.map(item => (item.id === result.id ? result : item)) + : [result, ...nodes]; + + yield put(flowSetNodes(updated_flow_nodes)); + + const { current } = yield select(selectNode); + + if (node.id && current.id === result.id) { + yield put(nodeSetCurrent(result)); + } + return yield put(modalSetShown(false)); }