codeant-ai-for-open-source[bot] commented on code in PR #43108:
URL: https://github.com/apache/superset/pull/43108#discussion_r4129011476


##########
superset-frontend/src/dashboard/containers/DashboardPage.tsx:
##########
@@ -381,8 +410,14 @@ export const DashboardPage: FC<PageProps> = ({ idOrSlug }: 
PageProps) => {
   }, [addDangerToast, datasets, datasetsApiError, dispatch, isNotFoundError]);
 
   const relevantDataMask = useSelector(selectRelevantDatamask);
+  const fullDataMask = useSelector(selectDataMask);
   const activeFilters = useSelector(selectActiveFilters);
 
+  useEffect(() => {
+    if (!id || hydratedDashboardId !== id) return;
+    saveDashboardFilters(id, fullDataMask);

Review Comment:
   The concern is valid. `nativeFilters` includes dividers and chart 
customizations, so using `Object.keys(nativeFilters)` can still serialize 
non-native entries whenever they exist in `fullDataMask`. Although restore 
later drops them, this causes unnecessary writes and storage serialization.
   
   The save path should derive its allowlist from the dashboard’s actual 
`native_filter_configuration`, matching the restore validation:
   
   ```ts
   const nativeFilterIds = new Set(
     (
       (dashboard?.metadata?.native_filter_configuration ?? []) as Array<
         NativeFilterConfigEntry | null | undefined
       >
     )
       .filter(
         (filter): filter is NativeFilterConfigEntry =>
           filter != null && !!filter.id,
       )
       .map(filter => filter.id),
   );
   
   const nativeFilterMask = Object.fromEntries(
     Object.entries(fullDataMask).filter(
       ([filterId]) => nativeFilterIds.has(filterId),
     ),
   );
   
   if (Object.keys(nativeFilterMask).length === 0) return;
   
   saveDashboardFilters(id, userId, nativeFilterMask, nativeFilters);
   ```
   
   This ensures chart customizations, dividers, and synthetic/transient entries 
are excluded before serialization, rather than merely being discarded during 
restore. The change is necessary to keep persistence limited to the feature’s 
intended native-filter state and avoid redundant writes.



-- 
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