Skip to content

Commit

Permalink
Use generated fed-modules.json
Browse files Browse the repository at this point in the history
  • Loading branch information
Hyperkid123 committed Nov 20, 2024
1 parent cbea8ff commit e225edb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/state/atoms/localSearchAtom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type SearchEntry = {
altTitle?: string[];
};

const GENERATED_SEARCH_FLAG = '@chrome:generated-search-index';
export const GENERATED_SEARCH_FLAG = '@chrome:generated-search-index';
type GeneratedSearchIndexResponse = {
alt_title?: string[];
id: string;
Expand Down
12 changes: 9 additions & 3 deletions src/utils/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ChromeModule, NavItem, RouteDefinition } from '../@types/types';
import axios from 'axios';
import { Required } from 'utility-types';
import useBundle, { getUrl } from '../hooks/useBundle';
import { GENERATED_SEARCH_FLAG } from '../state/atoms/localSearchAtom';

export const DEFAULT_SSO_ROUTES = {
prod: {
Expand Down Expand Up @@ -356,10 +357,14 @@ const loadCSCFedModules = () =>
headers: fedModulesheaders,
});

export const loadFedModules = async () =>
Promise.all([
export const loadFedModules = async () => {
const fedModulesPath =
localStorage.getItem(GENERATED_SEARCH_FLAG) === 'true'
? '/api/chrome-service/v1/static/fed-modules-generated.json'
: `${getChromeStaticPathname('modules')}/fed-modules.json`;
return Promise.all([
axios
.get(`${getChromeStaticPathname('modules')}/fed-modules.json`, {
.get(fedModulesPath, {
headers: fedModulesheaders,
})
.catch(loadCSCFedModules),
Expand All @@ -370,6 +375,7 @@ export const loadFedModules = async () =>
}
return staticConfig;
});
};

export const generateRoutesList = (modules: { [key: string]: ChromeModule }) =>
Object.entries(modules)
Expand Down

0 comments on commit e225edb

Please sign in to comment.