EnxDev commented on code in PR #35265:
URL: https://github.com/apache/superset/pull/35265#discussion_r2524386414
##########
superset-frontend/src/dashboard/components/gridComponents/Tab/Tab.jsx:
##########
@@ -114,6 +119,43 @@ const renderDraggableContent = dropProps =>
const Tab = props => {
const dispatch = useDispatch();
const canEdit = useSelector(state => state.dashboardInfo.dash_edit_perm);
+ const dashboardLayout = useSelector(state => state.dashboardLayout.present);
+ const lastRefreshTime = useSelector(
+ state => state.dashboardState.lastRefreshTime,
+ );
+ const tabActivationTime = useSelector(
+ state => state.dashboardState.tabActivationTimes?.[props.id] || 0,
+ );
+ const dashboardInfo = useSelector(state => state.dashboardInfo);
+
+ useEffect(() => {
+ if (props.renderType === RENDER_TAB_CONTENT && props.isComponentVisible) {
+ if (
+ lastRefreshTime &&
+ tabActivationTime &&
+ lastRefreshTime > tabActivationTime
+ ) {
+ const chartIds = getChartIdsFromComponent(props.id, dashboardLayout);
+ if (chartIds.length > 0) {
+ requestAnimationFrame(() => {
+ setTimeout(() => {
+ dispatch(onRefresh(chartIds, true, 0, dashboardInfo.id));
+ }, CHART_MOUNT_DELAY);
+ });
+ }
+ }
+ }
+ }, [
+ props.isComponentVisible,
+ props.renderType,
+ props.id,
+ lastRefreshTime,
+ tabActivationTime,
+ dashboardLayout,
Review Comment:
You're right; this version still depends on `dashboardLayout`, so it
wouldn't reduce the number of re-renders.
My intention was to make the dependency more focused on the actual chart IDs.
Maybe we could extract only the needed data from `dashboardLayout` (e.g.,
the chart IDs for the current tab) and make that part more stable instead?
--
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]