Skip to content

Commit

Permalink
Listen to redirect message
Browse files Browse the repository at this point in the history
  • Loading branch information
teodorus-nathaniel committed Mar 5, 2024
1 parent cee76ed commit ee7e643
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/components/profile-selector/MyAccountMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useRouter } from 'next/router'
import React, { createContext, FC, useContext, useEffect, useRef, useState } from 'react'
import { getCurrentUrlOrigin } from 'src/utils/url'
import { InfoDetails } from '../profiles/address-views'
Expand Down Expand Up @@ -73,6 +74,7 @@ function parseMessage(data: string) {
export const AccountMenu: React.FunctionComponent<AddressProps> = ({ address, owner }) => {
const iframeRef = useRef<HTMLIFrameElement | null>(null)
const [isOpenProfileModal, setIsOpenProfileModal] = useState(false)
const router = useRouter()

useEffect(() => {
window.onmessage = event => {
Expand All @@ -82,6 +84,8 @@ export const AccountMenu: React.FunctionComponent<AddressProps> = ({ address, ow
const { name, value } = message
if (name === 'profile' && value === 'close') {
setIsOpenProfileModal(false)
} else if (name === 'redirect') {
router.push(value)
}
}
}, [])
Expand Down

0 comments on commit ee7e643

Please sign in to comment.