msyavuz commented on code in PR #45928:
URL: https://github.com/apache/superset/pull/45928#discussion_r4440664704
##########
superset-frontend/src/dashboard/containers/DashboardPage.tsx:
##########
@@ -325,37 +455,47 @@ export const DashboardPage: FC<PageProps> = ({ idOrSlug
}: PageProps) => {
}
if (readyToRender) {
- if (!isDashboardHydrated.current) {
- isDashboardHydrated.current = true;
- }
- dispatch(
- hydrateDashboard({
- history,
- dashboard: dashboard!,
- charts: charts!,
- activeTabs: activeTabs ?? null,
- dataMask,
- chartStates: chartStates ?? null,
- } as unknown as Parameters<typeof hydrateDashboard>[0]),
- );
- dispatch(clearDashboardHistory());
-
- // Scroll to anchor element if specified in permalink state
- if (anchor) {
- // Use setTimeout to ensure the DOM has been updated after hydration
- setTimeout(() => {
- const element = document.getElementById(anchor);
- if (element) {
- element.scrollIntoView({ behavior: 'smooth' });
- }
- }, 0);
- }
+ hydrateWithState({ dataMask, activeTabs, chartStates, anchor });
}
return null;
}
- if (id) getDataMaskApplied();
+ if (id && readyToRender) getDataMaskApplied();
+ return () => {
+ cancelled = true;
+ controller.abort();
+ retryController.current?.abort();
+ };
// eslint-disable-next-line react-hooks/exhaustive-deps
- }, [readyToRender]);
+ }, [readyToRender, id]);
+
+ // Once the viewer changes a filter the saved state must not be re-applied
+ // over their change, so the banner (and its Try again action) goes away.
+ useEffect(
+ () => subscribeFilterKeyPublishRelease(() => setSharedStateNotice(null)),
+ [],
+ );
+
+ const retrySharedState = useCallback(async () => {
+ const source = sharedStateSource.current;
+ if (!source) return;
+ retryController.current?.abort();
+ const controller = new AbortController();
+ retryController.current = controller;
+ setIsRetryingSharedState(true);
+ const result: SharedStateResult<unknown> = await fetchSharedState(
+ source,
+ controller.signal,
+ );
+ if (controller.signal.aborted) return;
+ setIsRetryingSharedState(false);
+ if (result.status !== 'ok') {
+ setSharedStateNotice(result.status === 'expired' ? 'expired' : 'failed');
+ return;
+ }
+ hydrateWithStateRef.current(toSharedState(source, result.value));
Review Comment:
Addressed in ea872996dd. The hold is now released on every user-originated
filter change, not only Apply: chart-click cross-filters (in chartAction's
setDataMask, filter changes only, so own-state such as pagination keeps the
hold), the context-menu cross-filter, removing a cross-filter tag, filters
applied from chat in useDashboardFilterSync, and filters set by an embedded
host. Each one hides the banner, so Try again is no longer offered over those
changes.
##########
superset-frontend/src/dashboard/util/loadSharedFilterState.ts:
##########
@@ -0,0 +1,101 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { logging } from '@apache-superset/core/utils';
+
+// Upper bound on a single attempt to load shared filter state.
+export const SHARED_STATE_ATTEMPT_TIMEOUT_MS = 3000;
Review Comment:
Raised to 6 s per attempt in ea872996dd, so a uniformly slow backend at ~4 s
succeeds on the first attempt. Worst case before the fallback is 12.5 s. Also
in that commit: a stored value that fails JSON.parse is classed as expired
instead of retried, and the stuck isRetryingSharedState / isLoadingSharedState
flags are reset at the start of each load.
--
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]