Fix bug where toggling backend experiment also updates frontend

This commit is contained in:
Moon 2022-02-28 12:18:16 -08:00
parent 525f86faeb
commit 98ad392109
3 changed files with 5 additions and 1 deletions

View File

@ -51,6 +51,7 @@ export function* toggleExperiment( experimentName, currentVariation, source ) {
type: TYPES.TOGGLE_EXPERIMENT,
experimentName,
newVariation,
source,
};
}

View File

@ -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,
} ) ),

View File

@ -20,6 +20,7 @@ function Experiments( { experiments, toggleExperiment } ) {
<tr>
<th>Experiment</th>
<th>Variation</th>
<th>Source</th>
<th>Toggle</th>
</tr>
</thead>
@ -32,6 +33,7 @@ function Experiments( { experiments, toggleExperiment } ) {
{ name }
</td>
<td align="center">{ variation }</td>
<td align="center">{ source }</td>
<td align="center">
<Button
onClick={ () => {