Skip to content

Commit

Permalink
filter ordinals modal show once dev (#272)
Browse files Browse the repository at this point in the history
  • Loading branch information
gbarkhatov authored Oct 31, 2024
1 parent 061f71c commit 1a9683a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/app/common/constants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export const OVERFLOW_TVL_WARNING_THRESHOLD = 0.2;
export const OVERFLOW_HEIGHT_WARNING_THRESHOLD = 3;
export const UTXO_KEY = "UTXOs";
export const FILTER_ORDINALS_MODAL_KEY = "bbn-staking-filter-ordinals-modal";
20 changes: 17 additions & 3 deletions src/app/components/Modals/FilterOrdinalsModal.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { useEffect, useState } from "react";
import { IoMdClose } from "react-icons/io";
import { useLocalStorage } from "usehooks-ts";

import { FILTER_ORDINALS_MODAL_KEY } from "@/app/common/constants";
import { useBTCWallet } from "@/app/context/wallet/BTCWalletProvider";
import { useWalletConnection } from "@/app/context/wallet/WalletConnectionProvider";
import { useAppState } from "@/app/state";

Expand All @@ -10,16 +13,27 @@ interface FilterOrdinalsModalProps {}

export const FilterOrdinalsModal: React.FC<FilterOrdinalsModalProps> = ({}) => {
const [modalOpen, setModalOpen] = useState(false);
const handleClose = () => setModalOpen(false);
const { address } = useBTCWallet();

const handleClose = () => {
setModalOpen(false);
setHasSeenFilterOrdinalsModal((prev) => ({
...prev,
[address]: true,
}));
};

const { isConnected } = useWalletConnection();
const { ordinalsExcluded, includeOrdinals, excludeOrdinals } = useAppState();

const [hasSeenFilterOrdinalsModal, setHasSeenFilterOrdinalsModal] =
useLocalStorage<Record<string, boolean>>(FILTER_ORDINALS_MODAL_KEY, {});

useEffect(() => {
if (isConnected) {
if (isConnected && address && !hasSeenFilterOrdinalsModal[address]) {
setModalOpen(true);
}
}, [isConnected]);
}, [isConnected, hasSeenFilterOrdinalsModal, address]);

return (
<GeneralModal open={modalOpen} onClose={handleClose}>
Expand Down

0 comments on commit 1a9683a

Please sign in to comment.