fix(viewer): 🐛 Avoid variables duplication
This commit is contained in:
@@ -37,7 +37,12 @@ export const AnswersContext = ({
|
|||||||
|
|
||||||
const updateVariables = (variables: VariableWithValue[]) =>
|
const updateVariables = (variables: VariableWithValue[]) =>
|
||||||
setResultValues((resultValues) => {
|
setResultValues((resultValues) => {
|
||||||
const updatedVariables = [...resultValues.variables, ...variables]
|
const updatedVariables = [
|
||||||
|
...resultValues.variables.filter((v) =>
|
||||||
|
variables.every((variable) => variable.id !== v.id)
|
||||||
|
),
|
||||||
|
...variables,
|
||||||
|
]
|
||||||
if (onVariablesUpdated) onVariablesUpdated(updatedVariables)
|
if (onVariablesUpdated) onVariablesUpdated(updatedVariables)
|
||||||
return {
|
return {
|
||||||
...resultValues,
|
...resultValues,
|
||||||
|
|||||||
Reference in New Issue
Block a user