fix: prevent UserButton from fetching user info even before click
This commit is contained in:
parent
0090f5dc90
commit
cbe1feb2a2
2 changed files with 6 additions and 4 deletions
|
@ -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 }
|
||||
|
|
|
@ -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 (
|
||||
<>
|
||||
|
|
Loading…
Reference in a new issue