fix: prevent UserButton from fetching user info even before click

This commit is contained in:
hippoz 2021-10-23 17:49:40 +03:00
parent 0090f5dc90
commit cbe1feb2a2
No known key found for this signature in database
GPG key ID: 7C52899193467641
2 changed files with 6 additions and 4 deletions

View file

@ -80,8 +80,8 @@ export default function ChannelCreateButton() {
{/* ugly: AnimatePresence is needed to animate the modal closing */}
<AnimatePresence>
{(isDialogOpen) && <Modal
width="500px"
height="300px"
width="425px"
height="275px"
title="Create a channel"
alignItems="center"
onClose={ handleClose }

View file

@ -10,6 +10,8 @@ export default function ChannelUserButton({ user, subtext }) {
const [userObject, setUserObject] = useState(null);
useEffect(() => {
if (!isPromptOpen) return;
if (userObject) return;
authenticated(`/api/v1/users/user/${user._id}/info`, {
method: 'GET',
headers: {
@ -20,7 +22,7 @@ export default function ChannelUserButton({ user, subtext }) {
setUserObject(json.user);
}
});
}, [user]);
}, [user, isPromptOpen, userObject]);
return (
<>