Skip to content

Commit

Permalink
refactor: revert iframe listener
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelTaylor3D committed Aug 16, 2023
1 parent 2b5e86e commit 83a64c6
Showing 1 changed file with 0 additions and 33 deletions.
33 changes: 0 additions & 33 deletions src/components/blocks/MyAccount.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,39 +57,6 @@ const MyAccount = ({ openModal = false, onClose, isHeader = true }) => {
}
}, []);

useEffect(() => {
// Function to handle the message event
const handleMessage = event => {
if (event.origin !== window.location.origin) {
return;
}
console.log('Received message:', event.data);
if (
event?.data?.serverAddress &&
validateUrl(event?.data?.serverAddress)
) {
dispatch(
signIn({
apiKey: event?.data?.apiKey,
serverAddress: event?.data?.serverAddress,
}),
);
setServerAddress(null);
setApiKey(null);
setIsLogInModalOpen(false);
}
};

// Add the event listener
window.addEventListener('message', handleMessage, false);

// Return a function that will be called when the component unmounts
return () => {
// Remove the event listener
window.removeEventListener('message', handleMessage, false);
};
}, []);

return (
<StyledMyAccountContainer>
{isHeader && (
Expand Down

0 comments on commit 83a64c6

Please sign in to comment.