From 98ad39210967fcc9d828cafd6b38f1b99f460df4 Mon Sep 17 00:00:00 2001 From: Moon Date: Mon, 28 Feb 2022 12:18:16 -0800 Subject: [PATCH] Fix bug where toggling backend experiment also updates frontend --- src/experiments/data/actions.js | 1 + src/experiments/data/reducer.js | 3 ++- src/experiments/index.js | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/experiments/data/actions.js b/src/experiments/data/actions.js index 16716d534da..18e74e00b06 100644 --- a/src/experiments/data/actions.js +++ b/src/experiments/data/actions.js @@ -51,6 +51,7 @@ export function* toggleExperiment( experimentName, currentVariation, source ) { type: TYPES.TOGGLE_EXPERIMENT, experimentName, newVariation, + source, }; } diff --git a/src/experiments/data/reducer.js b/src/experiments/data/reducer.js index 2bb33b6dded..9d9fdb60863 100644 --- a/src/experiments/data/reducer.js +++ b/src/experiments/data/reducer.js @@ -15,7 +15,8 @@ const reducer = ( state = DEFAULT_STATE, action ) => { experiments: state.experiments.map( ( experiment ) => ( { ...experiment, variation: - experiment.name === action.experimentName + experiment.name === action.experimentName && + experiment.source === action.source ? action.newVariation : experiment.variation, } ) ), diff --git a/src/experiments/index.js b/src/experiments/index.js index 15fcdad264a..89c6f7e1e3b 100644 --- a/src/experiments/index.js +++ b/src/experiments/index.js @@ -20,6 +20,7 @@ function Experiments( { experiments, toggleExperiment } ) { Experiment Variation + Source Toggle @@ -32,6 +33,7 @@ function Experiments( { experiments, toggleExperiment } ) { { name } { variation } + { source }