window.clearTimeout(this.watchStatusTimer);
}
- fetchComponent = async (shouldRedirectToDashboard = false) => {
+ redirectIfNeeded = (componentWithQualifier: { key: string; qualifier: string }) => {
+ /*
+ * There used to be a redirect from /dashboard to /portfolio which caused issues.
+ * Links should be fixed to not rely on this redirect, but:
+ * This is a fail-safe in case there are still some faulty links remaining.
+ */
+ if (
+ this.props.location.pathname.includes('dashboard') &&
+ isPortfolioLike(componentWithQualifier.qualifier)
+ ) {
+ this.props.router.replace(getPortfolioUrl(componentWithQualifier.key));
+ }
+ };
+
+ fetchComponent = async (shouldRedirectToDashboard = false, backgroundLoading = false) => {
const { branch, id: key, pullRequest } = this.props.location.query;
- this.setState({ loading: true });
+ if (!backgroundLoading) {
+ this.setState({ loading: true });
+ }
let componentWithQualifier;
try {
componentWithQualifier = this.addQualifier({ ...nav, ...component });
} catch (e) {
if (this.mounted) {
- if (e && e instanceof Response && e.status === HttpStatus.Forbidden) {
+ if (e instanceof Response && e.status === HttpStatus.Forbidden) {
handleRequiredAuthorization();
} else {
this.setState({ component: undefined, loading: false });
return;
}
- /*
- * There used to be a redirect from /dashboard to /portfolio which caused issues.
- * Links should be fixed to not rely on this redirect, but:
- * This is a fail-safe in case there are still some faulty links remaining.
- */
- if (
- this.props.location.pathname.includes('dashboard') &&
- isPortfolioLike(componentWithQualifier.qualifier)
- ) {
- this.props.router.replace(getPortfolioUrl(componentWithQualifier.key));
- }
+ this.redirectIfNeeded(componentWithQualifier);
if (this.mounted) {
this.setState(
},
() => {
if (shouldFetchComponent) {
- this.fetchComponent(shouldRedirectToDashboard);
+ this.fetchComponent(shouldRedirectToDashboard, true);
}
},
);