Skip to content

Commit

Permalink
refactor: update to use subscribe insted of initialize
Browse files Browse the repository at this point in the history
  • Loading branch information
dcoa committed Nov 13, 2024
1 parent 8112bf8 commit f5c499f
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions src/components/Footer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ import PropTypes from 'prop-types';
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
import { sendTrackEvent } from '@edx/frontend-platform/analytics';
import {
ensureConfig, getConfig, mergeConfig, initialize,
APP_PUBSUB_INITIALIZED, APP_CONFIG_INITIALIZED, ensureConfig, getConfig, mergeConfig, subscribe,
} from '@edx/frontend-platform';
import { loadExternalScripts } from '@edx/frontend-platform/initialize';
import { AppContext } from '@edx/frontend-platform/react';

import { hydrateAuthenticatedUser } from '@edx/frontend-platform/auth';
import messages from './Footer.messages';
import LanguageSelector from './LanguageSelector';
import FooterLinks from './footer-links/FooterNavLinks';
Expand All @@ -21,18 +23,18 @@ ensureConfig([
'LOGO_POWERED_BY',
], 'Footer component');

initialize({
hydrateAuthenticatedUser: true,
externalScripts: [GoogleTagManagerLoader],
handlers: {
config: () => {
mergeConfig({
GOOGLE_TAG_MANAGER_ID: process.env.GOOGLE_TAG_MANAGER_ID || '',
GOOGLE_TAG_MANAGER_ENVIRONMENT: process.env.GOOGLE_TAG_MANAGER_ENVIRONMENT || '',
}, 'NauFooter');
},
},
messages: [messages],
subscribe(APP_PUBSUB_INITIALIZED, () => {
mergeConfig({
GOOGLE_TAG_MANAGER_ID: process.env.GOOGLE_TAG_MANAGER_ID || '',
GOOGLE_TAG_MANAGER_ENVIRONMENT: process.env.GOOGLE_TAG_MANAGER_ENVIRONMENT || '',
}, 'NauFooter');
});

subscribe(APP_CONFIG_INITIALIZED, async () => {
await hydrateAuthenticatedUser();
loadExternalScripts([GoogleTagManagerLoader], {
config: getConfig(),
});
});

const EVENT_NAMES = {
Expand Down Expand Up @@ -178,6 +180,5 @@ SiteFooter.defaultProps = {
supportedLanguages: [],
};


export default injectIntl(SiteFooter);
export { EVENT_NAMES };

0 comments on commit f5c499f

Please sign in to comment.