Skip to content

Commit

Permalink
feat(mfi-v2-ui): fix local storage rehydration
Browse files Browse the repository at this point in the history
  • Loading branch information
losman0s committed Oct 6, 2023
1 parent e56dd4b commit 0d89597
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
6 changes: 4 additions & 2 deletions apps/marginfi-v2-ui/next.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const withPWA = require('next-pwa')({
dest: 'public'
dest: 'public',
disable: process.env.NODE_ENV === 'development',
runtimeCaching: "CacheFirst",
})

const withBundleAnalyzer = require("@next/bundle-analyzer")({
Expand Down Expand Up @@ -110,4 +112,4 @@ config = withSentryConfig(
}
);

module.exports = process.env.NODE_ENV === 'development' ? config : withPWA(config);
module.exports = withPWA(config);
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const MobileAssetsList: FC = () => {
const togglePositions = () => setIsFiltered((previousState) => !previousState);

const { connected } = useWalletContext();
const [isStoreInitialized, sortedBanks, nativeSolBalance, selectedAccount] = useMrgnlendStore((state) => [
const [isStoreInitialized, extendedBankInfos, nativeSolBalance, selectedAccount] = useMrgnlendStore((state) => [
state.initialized,
state.extendedBankInfos,
state.nativeSolBalance,
Expand All @@ -29,6 +29,7 @@ export const MobileAssetsList: FC = () => {
if (sortOption.field === "APY") {
return sortApRate(banks, isInLendingMode, sortOption.direction);
} else if (sortOption.field === "TVL") {
console.log(sortTvl)
return sortTvl(banks, sortOption.direction);
} else {
return banks;
Expand All @@ -39,26 +40,26 @@ export const MobileAssetsList: FC = () => {

const globalBanks = useMemo(() => {
const filteredBanks =
sortedBanks &&
sortedBanks.filter((b) => !b.info.state.isIsolated).filter((b) => (isFiltered ? b.isActive : true));
extendedBankInfos &&
extendedBankInfos.filter((b) => !b.info.state.isIsolated).filter((b) => (isFiltered ? b.isActive : true));

if (sortOption && filteredBanks) {
if (isStoreInitialized && sortOption && filteredBanks) {
return sortBanks(filteredBanks);
} else {
return filteredBanks;
}
}, [sortedBanks, sortOption, isFiltered, sortBanks]);
}, [isStoreInitialized, extendedBankInfos, sortOption, isFiltered, sortBanks]);

const isolatedBanks = useMemo(() => {
const filteredBanks =
sortedBanks && sortedBanks.filter((b) => b.info.state.isIsolated).filter((b) => (isFiltered ? b.isActive : true));
extendedBankInfos && extendedBankInfos.filter((b) => b.info.state.isIsolated).filter((b) => (isFiltered ? b.isActive : true));

if (sortOption && filteredBanks) {
if (isStoreInitialized && sortOption && filteredBanks) {
return sortBanks(filteredBanks);
} else {
return filteredBanks;
}
}, [sortedBanks, sortOption, isFiltered, sortBanks]);
}, [isStoreInitialized, extendedBankInfos, sortOption, isFiltered, sortBanks]);

const handleSortChange = (event: SelectChangeEvent) => {
setSortOption(SORT_OPTIONS_MAP[event.target.value as SortType]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { WalletConnectModal } from "@walletconnect/modal";
const modal = new WalletConnectModal({
projectId: "69125c28c9733812e7b6653a2222cb0e",
chains: ["solana:4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ"],
explorerRecommendedWalletIds: ["a797aa35c0fadbfc1a53e7f675162ed5226968b44a19ee3d24385c64d1d3c393"]
});

const WalletSelector: FC<{ featuredWallets?: number }> = ({ featuredWallets = 3 }) => {
Expand Down

0 comments on commit 0d89597

Please sign in to comment.