Skip to content

Commit

Permalink
fix(accounts): ui refresh on loadPlayer (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
daZepelin committed Sep 12, 2022
1 parent 84a08a3 commit b726f51
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion web/src/App.tsx
Expand Up @@ -6,6 +6,7 @@ import 'dayjs/locale/sv';
import React, { useEffect, useState } from 'react';
import { useNuiEvent } from 'react-fivem-hooks';
import { useTranslation } from 'react-i18next';
import { useAtom } from 'jotai';
import { Route } from 'react-router-dom';
import './App.css';
import { useConfig } from './hooks/useConfig';
Expand All @@ -22,6 +23,8 @@ import { NUIEvents, UserEvents } from '@typings/Events';
import Deposit from './views/Deposit/Deposit';
import { fetchNui } from '@utils/fetchNui';
import Withdraw from './views/Withdraw/Withdraw';
import { accountsAtom } from '@data/accounts';
import { transactionBaseAtom } from '@data/transactions';

dayjs.extend(updateLocale);

Expand All @@ -47,9 +50,15 @@ const Content = styled.div`
const App: React.FC = () => {
const config = useConfig();
const [hasLoaded, setHasLoaded] = useState(process.env.NODE_ENV === 'development');
const [, updateAccounts] = useAtom(accountsAtom);
const [, updateTransactions] = useAtom(transactionBaseAtom);
useNuiEvent({
event: UserEvents.Loaded,
callback: () => setHasLoaded(true),
callback: () => {
setHasLoaded(true);
updateAccounts();
updateTransactions();
},
});

useNuiEvent({ event: UserEvents.Unloaded, callback: () => setHasLoaded(false) });
Expand Down

0 comments on commit b726f51

Please sign in to comment.