From ed94887f7c3892d4b220781239c2d940de44e9cb Mon Sep 17 00:00:00 2001 From: Adam Chambers Date: Fri, 24 Nov 2023 11:39:40 -0500 Subject: [PATCH] feat: hide new asset banner --- .../common/AssetList/NewAsssetBanner.tsx | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/apps/marginfi-v2-ui/src/components/common/AssetList/NewAsssetBanner.tsx b/apps/marginfi-v2-ui/src/components/common/AssetList/NewAsssetBanner.tsx index d26a57c875..791325c2d7 100644 --- a/apps/marginfi-v2-ui/src/components/common/AssetList/NewAsssetBanner.tsx +++ b/apps/marginfi-v2-ui/src/components/common/AssetList/NewAsssetBanner.tsx @@ -21,6 +21,8 @@ export const NewAssetBanner = ({ asset, image }: NewAssetBannerProps) => { state.setIsFilteredUserPositions, ]); + const [isHidden, setIsHidden] = React.useState(true); + const assetTicker = React.useMemo(() => "$" + asset.toUpperCase(), [asset]); const highlightAsset = React.useCallback(() => { @@ -30,7 +32,7 @@ export const NewAssetBanner = ({ asset, image }: NewAssetBannerProps) => { console.log(asset, assetRow); if (!assetRow) return; - assetRows.forEach((row) => row.classList.add("opacity-30", "hover:bg-[#171C1F]")); + assetRows.forEach((row) => row.classList.add("opacity-30", "hover:!bg-[#171C1F]")); assetRow.scrollIntoView({ behavior: "smooth", block: "center" }); assetRow.classList.remove("opacity-30"); assetRow.classList.add("animate-pulse"); @@ -42,18 +44,30 @@ export const NewAssetBanner = ({ asset, image }: NewAssetBannerProps) => { const deposit = React.useCallback(() => { setLendingMode(LendingModes.LEND); - if (poolFilter === PoolTypes.GLOBAL) setPoolFilter(PoolTypes.ALL); + if (poolFilter === PoolTypes.ALL) setPoolFilter(PoolTypes.ALL); setIsFilteredUserPositions(false); setTimeout(() => highlightAsset(), 100); }, [setLendingMode, setPoolFilter, asset]); const borrow = React.useCallback(() => { setLendingMode(LendingModes.BORROW); - if (poolFilter === PoolTypes.GLOBAL) setPoolFilter(PoolTypes.ALL); + if (poolFilter === PoolTypes.ALL) setPoolFilter(PoolTypes.ALL); setIsFilteredUserPositions(false); setTimeout(() => highlightAsset(), 100); }, [setLendingMode, setPoolFilter, asset]); + const hideBanner = React.useCallback(() => { + setIsHidden(true); + localStorage.setItem("mfiHideNewAssetBanner", "true"); + }, [setIsHidden]); + + React.useEffect(() => { + const isHidden = localStorage.getItem("mfiHideNewAssetBanner"); + if (!isHidden) setIsHidden(false); + }, []); + + if (isHidden) return null; + return (
@@ -76,7 +90,7 @@ export const NewAssetBanner = ({ asset, image }: NewAssetBannerProps) => {
-