Skip to content

Commit

Permalink
chore: PR changes
Browse files Browse the repository at this point in the history
  • Loading branch information
borcherd committed Dec 4, 2024
1 parent e6cc98c commit 019a7c3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
21 changes: 18 additions & 3 deletions apps/marginfi-v2-ui/src/context/MrgnlendProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,20 @@ export const MrgnlendProvider: React.FC<{
const debounceId = React.useRef<NodeJS.Timeout | null>(null);
const { wallet, isOverride, connected } = useWallet();
const { connection } = useConnection();
const [fetchMrgnlendState, setIsRefreshingStore, resetUserData, userDataFetched] = useMrgnlendStore((state) => [
const [fetchMrgnlendState, setIsRefreshingStore, resetUserData, marginfiAccounts] = useMrgnlendStore((state) => [
state.fetchMrgnlendState,
state.setIsRefreshingStore,
state.resetUserData,
state.userDataFetched,

state.marginfiAccounts,
]);
const [fetchPriorityFee, fetchAccountLabels] = useUiStore((state) => [
state.fetchPriorityFee,
state.fetchAccountLabels,
state.accountLabels,
]);
const [fetchPriorityFee] = useUiStore((state) => [state.fetchPriorityFee]);

const [hasFetchedAccountLabels, setHasFetchedAccountLabels] = React.useState(false);

// identify user if logged in
React.useEffect(() => {
Expand Down Expand Up @@ -98,5 +105,13 @@ export const MrgnlendProvider: React.FC<{
}
}, [connected, resetUserData]);

// Fetch account labels
React.useEffect(() => {
if (marginfiAccounts.length > 0 && !hasFetchedAccountLabels) {
setHasFetchedAccountLabels(true);
fetchAccountLabels(marginfiAccounts);
}
}, [marginfiAccounts, fetchAccountLabels, hasFetchedAccountLabels]);

return <MrgnlendContext.Provider value={{}}>{children}</MrgnlendContext.Provider>;
};
13 changes: 1 addition & 12 deletions apps/marginfi-v2-ui/src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,11 @@ const Footer = dynamic(async () => (await import("~/components/desktop/Footer"))
type MrgnAppProps = { path: string };

export default function MrgnApp({ Component, pageProps, path }: AppProps & MrgnAppProps) {
const [broadcastType, priorityFees, isOraclesStale, setIsFetchingData, fetchAccountLabels] = useUiStore((state) => [
const [broadcastType, priorityFees, isOraclesStale, setIsFetchingData] = useUiStore((state) => [
state.broadcastType,
state.priorityFees,
state.isOraclesStale,
state.setIsFetchingData,
state.fetchAccountLabels,
]);
const [
isMrgnlendStoreInitialized,
Expand All @@ -62,7 +61,6 @@ export default function MrgnApp({ Component, pageProps, path }: AppProps & MrgnA
extendedBankInfos,
nativeSolBalance,
accountSummary,
marginfiAccounts,
] = useMrgnlendStore((state) => [
state.initialized,
state.isRefreshingStore,
Expand All @@ -71,13 +69,11 @@ export default function MrgnApp({ Component, pageProps, path }: AppProps & MrgnA
state.extendedBankInfos,
state.nativeSolBalance,
state.accountSummary,
state.marginfiAccounts,
]);

const { query, isReady } = useRouter();
const [ready, setReady] = React.useState(false);
const [rpcEndpoint, setRpcEndpoint] = React.useState("");
const [hasFetchedAccountLabels, setHasFetchedAccountLabels] = React.useState(false);

React.useEffect(() => {
const isFetchingData = isRefreshingMrgnlendStore;
Expand All @@ -95,13 +91,6 @@ export default function MrgnApp({ Component, pageProps, path }: AppProps & MrgnA
init();
}, []);

React.useEffect(() => {
if (marginfiAccounts.length > 0 && !hasFetchedAccountLabels) {
setHasFetchedAccountLabels(true);
fetchAccountLabels(marginfiAccounts);
}
}, [marginfiAccounts, fetchAccountLabels, hasFetchedAccountLabels]);

return (
<>
<Meta path={path} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ export const WalletAuthAccounts = ({
onClick={(e) => {
e.stopPropagation();
setEditingAccount(account);
setEditingAccountName(accountLabels?.[account.address.toBase58()] || "");
setEditingAccountName(accountLabel);
setWalletAuthAccountsState(WalletAuthAccountsState.EDIT_ACCOUNT);
}}
>
Expand Down

0 comments on commit 019a7c3

Please sign in to comment.