korbit-ai[bot] commented on code in PR #35754:
URL: https://github.com/apache/superset/pull/35754#discussion_r2446915411


##########
superset-frontend/src/embedded/api.tsx:
##########
@@ -65,9 +67,16 @@ const getActiveTabs = () => 
store?.getState()?.dashboardState?.activeTabs || [];
 
 const getDataMask = () => store?.getState()?.dataMask || {};
 
+const setDataMask = (dataMask: DataMaskStateWithId) => {
+  Object.entries(dataMask).forEach(([filterId, mask]) => {
+    store?.dispatch(updateDataMask(filterId, mask));
+  });
+};

Review Comment:
   ### Lack of batched updates for data mask <sub>![category 
Performance](https://img.shields.io/badge/Performance-4f46e5)</sub>
   
   <details>
     <summary>Tell me more</summary>
   
   ###### What is the issue?
   setDataMask dispatches an update action per filter entry instead of batching.
   
   
   ###### Why this matters
   Dispatching many actions sequentially can trigger multiple state updates and 
re-renders, increasing CPU work and UI latency when updating large masks.
   
   ###### Suggested change ∙ *Feature Preview*
   Wrap dispatches in a batch to apply all updates in a single render cycle, or 
implement a single action that updates the entire mask. Example using 
react-redux batch:
   ```ts
   import { batch } from 'react-redux';
   
   const setDataMask = (dataMask: DataMaskStateWithId) => {
     batch(() => {
       Object.entries(dataMask).forEach(([filterId, mask]) => {
         store?.dispatch(updateDataMask(filterId, mask));
       });
     });
   };
   ```
   
   
   ###### Provide feedback to improve future suggestions
   [![Nice 
Catch](https://img.shields.io/badge/👍%20Nice%20Catch-71BC78)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/d4110eef-81fc-4f26-881c-2843966178c7/upvote)
 
[![Incorrect](https://img.shields.io/badge/👎%20Incorrect-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/d4110eef-81fc-4f26-881c-2843966178c7?what_not_true=true)
  [![Not in 
Scope](https://img.shields.io/badge/👎%20Out%20of%20PR%20scope-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/d4110eef-81fc-4f26-881c-2843966178c7?what_out_of_scope=true)
 [![Not in coding 
standard](https://img.shields.io/badge/👎%20Not%20in%20our%20standards-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/d4110eef-81fc-4f26-881c-2843966178c7?what_not_in_standard=true)
 
[![Other](https://img.shields.io/badge/👎%20Other-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/d4110eef-81fc-4f26-881c-2843966178c7)
   </details>
   
   <sub>
   
   💬 Looking for more details? Reply to this comment to chat with Korbit.
   </sub>
   
   <!--- korbi internal id:4c06f21d-e99a-4a8c-9a02-7aadae69a8d2 -->
   
   
   [](4c06f21d-e99a-4a8c-9a02-7aadae69a8d2)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to