Skip to content

Commit

Permalink
fix: axios get request for config
Browse files Browse the repository at this point in the history
  • Loading branch information
Fara Woolf authored and fbwoolf committed Nov 20, 2023
1 parent 6b75267 commit 3ad4b06
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/app/features/hiro-messages/in-app-messages.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Flex, FlexProps } from 'leather-styles/jsx';

import { useRemoteHiroMessages } from '@app/query/common/remote-config/remote-config.query';
import { useRemoteLeatherMessages } from '@app/query/common/remote-config/remote-config.query';
import { useCurrentNetworkState } from '@app/store/networks/networks.hooks';
import { useDismissMessage } from '@app/store/settings/settings.actions';
import { useDismissedMessageIds } from '@app/store/settings/settings.selectors';

import { HiroMessageItem } from './components/in-app-message-item';

export function InAppMessages(props: FlexProps) {
const messages = useRemoteHiroMessages();
const messages = useRemoteLeatherMessages();

const { mode } = useCurrentNetworkState();
const dismissMessage = useDismissMessage();
Expand Down
9 changes: 5 additions & 4 deletions src/app/query/common/remote-config/remote-config.query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,15 @@ const githubWalletConfigRawUrl = `https://raw.githubusercontent.com/${GITHUB_ORG
BRANCH_NAME || defaultBranch
}/config/wallet-config.json`;

async function fetchHiroMessages(): Promise<RemoteConfig> {
async function fetchLeatherMessages(): Promise<RemoteConfig> {
if ((!BRANCH_NAME && WALLET_ENVIRONMENT !== 'production') || IS_TEST_ENV)
return localConfig as RemoteConfig;
return axios.get(githubWalletConfigRawUrl);
const resp = await axios.get(githubWalletConfigRawUrl);
return resp.data;
}

function useRemoteConfig() {
const { data } = useQuery(['walletConfig'], fetchHiroMessages, {
const { data } = useQuery(['walletConfig'], fetchLeatherMessages, {
// As we're fetching from Github, a third-party, we want
// to avoid any unnecessary stress on their services, so
// we use quite slow stale/retry times
Expand All @@ -91,7 +92,7 @@ function useRemoteConfig() {
return data;
}

export function useRemoteHiroMessages(): HiroMessage[] {
export function useRemoteLeatherMessages(): HiroMessage[] {
const config = useRemoteConfig();
return get(config, 'messages.global', []);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/specs/settings/settings-menu.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ test.describe('Settings menu', () => {
test.expect(currentNetwork).toContain('mainnet');

await page.getByTestId(SettingsSelectors.ChangeNetworkAction).click();
await page.waitForTimeout(850);
await page.waitForTimeout(1000);
const networkListItems = await page.getByTestId(SettingsSelectors.NetworkListItem).all();
test.expect(networkListItems).toHaveLength(5);
});
Expand Down

0 comments on commit 3ad4b06

Please sign in to comment.