Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Known code errors fix #728

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/frontend/components/Shared/Charts/APYChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ type APYChartProps = {
function APYChart({ data, period, tab }: APYChartProps) {
const { palette } = useTheme();

const normalizedData = normalizeChartData(data, tab, period);
const normalizedData = normalizeChartData(data, tab, period).filter(
(array) => array.data.length > 0
);
const valuesToShow = xAxisValues(normalizedData, period);

const config: LineSvgProps = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import {
useMediaQuery,
} from '@mui/material';
import { useTheme } from '@mui/material/styles';
import { AbstractVault, VaultType } from '@x-fuji/sdk';
import { VaultType } from '@x-fuji/sdk';
import { useRouter } from 'next/router';
import React, { useEffect, useMemo, useRef, useState } from 'react';
import React, { useEffect, useMemo, useState } from 'react';

import { FetchStatus } from '../../../../helpers/assets';
import { useBorrow } from '../../../../store/borrow.store';
Expand All @@ -43,8 +43,6 @@ function VaultSelect({ type = VaultType.BORROW }: VaultSelectProps) {
const status = useStore().availableVaultsStatus;
const changeActiveVault = useStore().changeActiveVault;

const prevVault = useRef<AbstractVault | undefined>(undefined);

const hasNoAvailableVaults =
status === FetchStatus.Ready && availableVaults.length === 0;
const override = useNavigation(
Expand Down
20 changes: 20 additions & 0 deletions packages/frontend/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
navigationalTaskDelay,
pathForVaultType,
} from '../helpers/navigation';
import { notify } from '../helpers/notifications';
import { onboard, useAuth } from '../store/auth.store';
import { useHistory } from '../store/history.store';
import { useNavigation } from '../store/navigation.store';
Expand Down Expand Up @@ -101,6 +102,25 @@ function MyApp({ Component, pageProps }: AppProps) {
};
}, [address, router]);

useEffect(() => {
const onRedeploy = (e: ErrorEvent) => {
/** Warns user about application redeploy */
if (/Loading chunk [\d]+ failed/.test(e.message)) {
notify({
message: 'New version released, page will be reloaded',
type: 'info',
});

setTimeout(() => {
window.location.reload();
}, 3000);
}
};
window.addEventListener('error', onRedeploy);

return () => window.removeEventListener('error', onRedeploy);
}, []);

useEffect(() => {
const handleRouteChange = (url: string) => {
const isTop = isTopLevelUrl(url);
Expand Down
15 changes: 10 additions & 5 deletions packages/frontend/pages/borrow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,16 @@ const BorrowPage: NextPage = () => {

const [hasChain, setHasChain] = useState(false);

if (shouldResetPage) {
clearDebt();
clearInputValues();
navigationalTaskDelay(() => changeShouldPageReset(VaultType.BORROW, false));
}
useEffect(() => {
if (shouldResetPage) {
clearDebt();
clearInputValues();
navigationalTaskDelay(() =>
changeShouldPageReset(VaultType.BORROW, false)
);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

useEffect(() => {
changeFormType(formType);
Expand Down
11 changes: 7 additions & 4 deletions packages/frontend/pages/lend.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@ const LendingPage: NextPage = () => {

const [hasChain, setHasChain] = useState(false);

if (shouldResetPage) {
clearInputValues();
navigationalTaskDelay(() => changeShouldPageReset(VaultType.LEND, false));
}
useEffect(() => {
if (shouldResetPage) {
clearInputValues();
navigationalTaskDelay(() => changeShouldPageReset(VaultType.LEND, false));
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

useEffect(() => {
changeFormType(formType);
Expand Down