Skip to content

Commit

Permalink
fix opened event
Browse files Browse the repository at this point in the history
  • Loading branch information
jonator committed Nov 4, 2024
1 parent 22078b5 commit 9822d07
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions packages/web/modals/variants-conversion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { EventName } from "~/config";
import {
useAmplitudeAnalytics,
useAssetVariantsToast,
useLocalStorageState,
useTranslation,
useWindowSize,
} from "~/hooks";
Expand All @@ -25,8 +24,6 @@ import { ModalBase } from "~/modals";
import { useStore } from "~/stores";
import { api } from "~/utils/trpc";

export const CONVERT_VARIANT_MODAL_SEEN = "convert-variant-modal-seen";

export const useAssetVariantsModalStore = create<{
isOpen: boolean;
variantCoinMinimalDenom?: string;
Expand All @@ -48,11 +45,6 @@ export const AssetVariantsConversionModal = observer(() => {
useAssetVariantsModalStore();
useAssetVariantsToast();

const [, setIsShown] = useLocalStorageState(
CONVERT_VARIANT_MODAL_SEEN,
false
);

const { accountStore } = useStore();
const account = accountStore.getWallet(accountStore.osmosisChainId);
const { isMobile } = useWindowSize();
Expand Down Expand Up @@ -86,16 +78,19 @@ export const AssetVariantsConversionModal = observer(() => {
}
);

// should close toast if screen size changes to mobile while shown
// Log when opened
useEffect(() => {
if (isOpen) {
setIsShown(true);
logEvent([EventName.ConvertVariants.startFlow]);
}
}, [isOpen, logEvent]);

// should close toast if screen size changes to mobile while shown
useEffect(() => {
if (isMobile && isOpen) {
setIsOpen(false);
}
}, [isOpen, isMobile, setIsOpen, setIsShown, logEvent]);
}, [isOpen, isMobile, setIsOpen]);

return (
<ModalBase
Expand Down

0 comments on commit 9822d07

Please sign in to comment.