Skip to content

Commit

Permalink
prevent conflict with #2670
Browse files Browse the repository at this point in the history
  • Loading branch information
benedikt-bartscher committed Feb 20, 2024
1 parent 7ca5451 commit 63720e8
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions reflex/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -1330,19 +1330,28 @@ def dict(self, include_computed: bool = True, **kwargs) -> dict[str, Any]:
self.dirty_vars.update(self._always_dirty_computed_vars)
self._mark_dirty()

if include_computed:
variables = {**self.base_vars, **self.computed_vars}
else:
variables = self.base_vars
base_vars = {
prop_name: self.get_value(getattr(self, prop_name), include=self.base_vars[prop_name]._var_used_attributes) # type: ignore[call-arg]
for prop_name in self.base_vars
if self.base_vars[prop_name]._var_is_used
or prop_name == constants.ROUTER
or prop_name == constants.CompileVars.IS_HYDRATED
}

computed_vars = (
{
# Include the computed vars.
prop_name: self.get_value(getattr(self, prop_name), include=self.computed_vars[prop_name]._var_used_attributes) # type: ignore[call-arg]
for prop_name in self.computed_vars
if self.computed_vars[prop_name]._var_is_used
}
if include_computed
else {}
)
variables = {**base_vars, **computed_vars}

d = {
self.get_full_name(): {
k: self.get_value(getattr(self, k), include=variables[k]._var_used_attributes) # type: ignore[call-arg]
for k in sorted(variables)
if variables[k]._var_is_used
or k == constants.ROUTER
or k == constants.CompileVars.IS_HYDRATED
},
self.get_full_name(): {k: variables[k] for k in sorted(variables)},
}
for substate_d in [
v.dict(include_computed=include_computed, **kwargs)
Expand Down

0 comments on commit 63720e8

Please sign in to comment.