From d4ddb025a44926423a63ec1b35d35310f36f823e Mon Sep 17 00:00:00 2001 From: Laurent Bossavit Date: Tue, 26 Sep 2017 17:20:46 +0200 Subject: [PATCH] =?UTF-8?q?:bug:=20Corrige=20la=20pr=C3=A9c=C3=A9dence=20e?= =?UTF-8?q?ntre=20hypoth=C3=A8ses=20et=20valeur=20de=20conversation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/reducers.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/source/reducers.js b/source/reducers.js index 8ba4b1b88..90c7ad5a9 100644 --- a/source/reducers.js +++ b/source/reducers.js @@ -16,8 +16,10 @@ let fromConversation = state => name => formValueSelector('conversation')(state, // assume "wraps" a given situation function with one that overrides its values with // the given assumptions -let assume = (evaluator, assumptions) => state => name => - assumptions[name] != null ? assumptions[name] : evaluator(state)(name) +let assume = (evaluator, assumptions) => state => name => { + let userInput = evaluator(state)(name) + return userInput != null ? userInput : assumptions[name] + } export let reduceSteps = (state, action) => { @@ -39,7 +41,7 @@ export let reduceSteps = (state, action) => { let situationGate = completeSituation(state), analysedSituation = analyseTopDown(flatRules,rootVariable)(situationGate) - let returnObject = { + let newState = { ...state, analysedSituation, situationGate: situationGate @@ -47,14 +49,14 @@ export let reduceSteps = (state, action) => { if (action.type == START_CONVERSATION) { return { - ...returnObject, + ...newState, foldedSteps: [], - unfoldedSteps: buildNextSteps(situationGate, flatRules, returnObject.analysedSituation) + unfoldedSteps: buildNextSteps(situationGate, flatRules, newState.analysedSituation) } } if (action.type == STEP_ACTION && action.name == 'fold') { let foldedSteps = [...state.foldedSteps, R.head(state.unfoldedSteps)], - unfoldedSteps = buildNextSteps(situationGate, flatRules, returnObject.analysedSituation) + unfoldedSteps = buildNextSteps(situationGate, flatRules, newState.analysedSituation) // The simulation is "over" - except we can now fill in extra questions // where the answers were previously given reasonable assumptions @@ -64,15 +66,15 @@ export let reduceSteps = (state, action) => { extraSteps = buildNextSteps(newSituation, flatRules, reanalyse) return { - ...returnObject, + ...newState, foldedSteps, extraSteps, - unfoldedSteps + unfoldedSteps: [] } } return { - ...returnObject, + ...newState, foldedSteps, unfoldedSteps } @@ -83,7 +85,7 @@ export let reduceSteps = (state, action) => { extraSteps = R.reject(stepFinder)(state.extraSteps) return { - ...returnObject, + ...newState, foldedSteps, extraSteps, unfoldedSteps: [R.find(stepFinder)(R.concat(state.foldedSteps,state.extraSteps))]