Skip to content

Commit

Permalink
chore: PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
brobro10000 committed Mar 5, 2024
1 parent 571e680 commit 1fa97bc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 26 deletions.
6 changes: 1 addition & 5 deletions src/components/app/Root.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const Root = () => {
}
}, NPROGRESS_DELAY_MS);
return () => clearTimeout(timeoutId);
}, [navigation, fetchers, authenticatedUser]);
}, [navigation, fetchers]);

// in the special case where there is not authenticated user and we are being told it's the logout
// flow, we can show the logout message safely.
Expand All @@ -56,10 +56,6 @@ const Root = () => {
);
}

if (!authenticatedUser.profileImage) {
return null;
}

// User is authenticated, so render the child routes (rest of the app).
return (
<>
Expand Down
39 changes: 18 additions & 21 deletions src/components/app/routes/data/services.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { camelCaseObject, getConfig } from '@edx/frontend-platform';
import { getAuthenticatedHttpClient, getAuthenticatedUser } from '@edx/frontend-platform/auth';
import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth';
import { logError, logInfo } from '@edx/frontend-platform/logging';
import {
ENTERPRISE_OFFER_STATUS,
Expand Down Expand Up @@ -367,26 +367,23 @@ export async function fetchSubscriptions(enterpriseUuid) {

// Notices
export const fetchNotices = async () => {
const authenticatedUser = getAuthenticatedUser();
const url = new URL(`${getConfig().LMS_BASE_URL}/notices/api/v1/unacknowledged`);
if (authenticatedUser) {
try {
const { data } = await getAuthenticatedHttpClient().get(url.href, {});
if (data?.results.length > 0) {
const { results } = data;
window.location.assign(`${results[0]}?next=${window.location.href}`);
throw new Error('Redirecting to notice');
}
return data;
} catch (error) {
// we will just swallow error, as that probably means the notices app is not installed.
// Notices are not necessary for the rest of dashboard to function.
const httpErrorStatus = getErrorResponseStatusCode(error);
if (httpErrorStatus === 404) {
logInfo(`${error}. This probably happened because the notices plugin is not installed on platform.`);
} else {
logError(error);
}
const url = `${getConfig().LMS_BASE_URL}/notices/api/v1/unacknowledged`;
try {
const { data } = await getAuthenticatedHttpClient().get(url);
if (data?.results.length > 0) {
const { results } = data;
window.location.assign(`${results[0]}?next=${window.location.href}`);
throw new Error('Redirecting to notice');
}
return data;
} catch (error) {
// we will just swallow error, as that probably means the notices app is not installed.
// Notices are not necessary for the rest of dashboard to function.
const httpErrorStatus = getErrorResponseStatusCode(error);
if (httpErrorStatus === 404) {
logInfo(`${error}. This probably happened because the notices plugin is not installed on platform.`);
} else {
logError(error);
}
}
return null;
Expand Down

0 comments on commit 1fa97bc

Please sign in to comment.