msyavuz commented on code in PR #35265:
URL: https://github.com/apache/superset/pull/35265#discussion_r2524297343
##########
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:
This would not help. It still depends on the dashboardLayout in your
example. It's just moving the computation from inside the effect to outside,
but with no performance gain.
--
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]