瀏覽代碼

add __full in symmetry to __patch

Khaleel Al-Adhami 2 月之前
父節點
當前提交
e0bf5b2ac9
共有 3 個文件被更改,包括 8 次插入6 次删除
  1. 1 1
      reflex/.templates/web/utils/state.js
  2. 4 2
      reflex/state.py
  3. 3 3
      tests/units/test_app.py

+ 1 - 1
reflex/.templates/web/utils/state.js

@@ -476,7 +476,7 @@ export const connect = async (
             last_substate_info[substate],
             update.delta[substate].__patch
           ).newDocument
-        : update.delta[substate];
+        : update.delta[substate].__full;
       last_substate_info[substate] = new_substate_info;
       dispatch[substate](new_substate_info);
     }

+ 4 - 2
reflex/state.py

@@ -233,9 +233,11 @@ def serialize_state_delta(delta: StateDelta) -> dict[str, Any]:
                     "__patch": make_patch(previous_delta, new_state_value).patch
                 }
             else:
-                full_delta[state_name] = new_state_value
+                full_delta[state_name] = {"__full": new_state_value}
         return full_delta
-    return delta.data
+    return {
+        state_name: {"__full": state_value} for state_name, state_value in delta.items()
+    }
 
 
 if environment.REFLEX_PERF_MODE.get() != PerformanceMode.OFF:

+ 3 - 3
tests/units/test_app.py

@@ -731,7 +731,7 @@ async def test_dict_mutation_detection__plain_list(
             FileUploadState,
             {
                 FileUploadState.get_full_name(): {
-                    "img_list": ["image1.jpg", "image2.jpg"]
+                    "__full": {"img_list": ["image1.jpg", "image2.jpg"]}
                 }
             },
         ),
@@ -739,7 +739,7 @@ async def test_dict_mutation_detection__plain_list(
             ChildFileUploadState,
             {
                 ChildFileUploadState.get_full_name(): {
-                    "img_list": ["image1.jpg", "image2.jpg"]
+                    "__full": {"img_list": ["image1.jpg", "image2.jpg"]}
                 }
             },
         ),
@@ -747,7 +747,7 @@ async def test_dict_mutation_detection__plain_list(
             GrandChildFileUploadState,
             {
                 GrandChildFileUploadState.get_full_name(): {
-                    "img_list": ["image1.jpg", "image2.jpg"]
+                    "__full": {"img_list": ["image1.jpg", "image2.jpg"]}
                 }
             },
         ),