Skip to content

Commit

Permalink
Merge branch 'add-memeContract' into add-memeContract-btcWallet
Browse files Browse the repository at this point in the history
  • Loading branch information
lq0-github committed Jan 20, 2025
2 parents ae6dc85 + f56b60a commit f2b1d00
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 35 deletions.
27 changes: 24 additions & 3 deletions components/BalanceReminder/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,46 @@ import { RemindCloseIcon, RemindIcon } from "./icon";
import { useAppSelector } from "../../redux/hooks";
import { getAccountId } from "../../redux/accountSelectors";
import { setAccountDetailsOpen, setActiveTab, setSelectedTab } from "../../redux/marginTabSlice";
import {
getMarginAccountSupplied,
getMarginAccountSuppliedMEME,
} from "../../redux/marginAccountSelectors";
import { useMarginAccount } from "../../hooks/useMarginAccount";

const BalanceReminder = () => {
const router = useRouter();
const { getAssetById, getAssetByIdMEME } = useMarginAccount();
const accountId = useAppSelector(getAccountId);
const [shouldShow, setShouldShow] = useState(false);
const accountSupplied = useAppSelector(getMarginAccountSupplied);
const accountSuppliedMEME = useAppSelector(getMarginAccountSuppliedMEME);
const combinedAccountSupplied = [
...accountSupplied.map((token) => ({ ...token, type: "main" })),
...accountSuppliedMEME.map((token) => ({ ...token, type: "meme" })),
];
const Unreminded = useMemo(() => {
const lastClosedDate = localStorage.getItem("balanceReminderLastClosed");
const today = new Date().toDateString();
return !lastClosedDate || lastClosedDate !== today;
}, []);
const dispatch = useDispatch();
useEffect(() => {
if (accountId && Unreminded) {
const hasValidAccountSupplied =
combinedAccountSupplied.length > 0 &&
combinedAccountSupplied.some((token) => {
const assetDetails =
token.type === "main" ? getAssetById(token.token_id) : getAssetByIdMEME(token.token_id);
return (
assetDetails && token.balance.toString().length >= assetDetails.config.extra_decimals
);
});

if (accountId && Unreminded && hasValidAccountSupplied) {
setShouldShow(true);
// setPersonalDataUpdatedSerialNumber(personalDataUpdatedSerialNumber + 1);
} else {
setShouldShow(false);
}
}, [accountId, router.pathname, Unreminded]);
}, [accountId, router.pathname, Unreminded, combinedAccountSupplied]);
const handleClaim = () => {
dispatch(setActiveTab("my"));
dispatch(setSelectedTab("account"));
Expand Down
55 changes: 38 additions & 17 deletions components/NonFarmedAssets/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,46 @@ function NonFarmedAssets() {
} = useNonFarmedAssets(true);
const main_null = !hasNonFarmedAssets || hasNegativeNetLiquidity;
const meme_null = !hasNonFarmedAssetsMEME || hasNegativeNetLiquidityMEME;
if (main_null && meme_null) return null;
return (
<div className="flex xsm:hidden xsm:gap-3 items-center justify-between mb-5 border border-primary border-opacity-60 bg-primary bg-opacity-5 rounded-xl p-3 pl-5">
<div className="flex items-start">
<WarnIcon className="relative top-px flex-shrink-0 xsm:hidden" />
<div className="text-sm text-white mx-2.5 xsm:mx-0">
At least one of your farms in the {main_null ? "meme" : "Mainstream"} has started emitting
extra rewards. If you are seeing this warning, please click ‘Claim & Join’ to join the new
farm.

if (!main_null) {
return (
<div className="flex xsm:hidden xsm:gap-3 items-center justify-between mb-5 border border-primary border-opacity-60 bg-primary bg-opacity-5 rounded-xl p-3 pl-5">
<div className="flex items-start">
<WarnIcon className="relative top-px flex-shrink-0 xsm:hidden" />
<div className="text-sm text-white mx-2.5 xsm:mx-0">
At least one of your farms in the Mainstream has started emitting extra rewards. If you
are seeing this warning, please click ‘Claim & Join’ to join the new farm.
</div>
</div>
<ClaimAllRewards
location="non-farmed-assets"
Button={ClaimButton}
disabled={hasNegativeNetLiquidity}
memeCategory={false}
/>
</div>
<ClaimAllRewards
location="non-farmed-assets"
Button={ClaimButton}
disabled={hasNegativeNetLiquidity}
memeCategory={main_null}
/>
</div>
);
);
} else if (meme_null) {
return (
<div className="flex xsm:hidden xsm:gap-3 items-center justify-between mb-5 border border-primary border-opacity-60 bg-primary bg-opacity-5 rounded-xl p-3 pl-5">
<div className="flex items-start">
<WarnIcon className="relative top-px flex-shrink-0 xsm:hidden" />
<div className="text-sm text-white mx-2.5 xsm:mx-0">
At least one of your farms in the meme has started emitting extra rewards. If you are
seeing this warning, please click ‘Claim & Join’ to join the new farm.
</div>
</div>
<ClaimAllRewards
location="non-farmed-assets"
Button={ClaimButton}
disabled={hasNegativeNetLiquidityMEME}
memeCategory={true}
/>
</div>
);
}

return null;
}

const ClaimButton = (props) => {
Expand Down
16 changes: 1 addition & 15 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,26 +115,12 @@ const Init = () => {
return null;
};
function Upgrade({ Component, pageProps }) {
const { getAssetById, getAssetByIdMEME } = useMarginAccount();
const [upgrading, setUpgrading] = useState<boolean>(true);
const accountSupplied = useAppSelector(getMarginAccountSupplied);
const accountSuppliedMEME = useAppSelector(getMarginAccountSuppliedMEME);
const combinedAccountSupplied = [
...accountSupplied.map((token) => ({ ...token, type: "main" })),
...accountSuppliedMEME.map((token) => ({ ...token, type: "meme" })),
];
const dispatch = useAppDispatch();
const accountId = useAppSelector(getAccountId);
const portfolio = useAppSelector(getAccountPortfolio());
const assets = useAppSelector(getAssets);
const config = useAppSelector(getConfig);
const hasValidAccountSupplied =
combinedAccountSupplied?.length > 0 &&
combinedAccountSupplied?.some((token) => {
const assetDetails =
token.type === "main" ? getAssetById(token.token_id) : getAssetByIdMEME(token.token_id);
return assetDetails && token.balance.toString().length >= assetDetails.config.extra_decimals;
});
useEffect(() => {
if (
!portfolio.positions ||
Expand Down Expand Up @@ -182,7 +168,7 @@ function Upgrade({ Component, pageProps }) {
<ToastMessage />
<Component {...pageProps} />
{/* <Popup className="xsm:hidden" /> */}
{hasValidAccountSupplied && <BalanceReminder />}
<BalanceReminder />
<RpcList />
<PubTestModal />
</Layout>
Expand Down

0 comments on commit f2b1d00

Please sign in to comment.