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 */}
|
{/* ugly: AnimatePresence is needed to animate the modal closing */}
|
||||||
<AnimatePresence>
|
<AnimatePresence>
|
||||||
{(isDialogOpen) && <Modal
|
{(isDialogOpen) && <Modal
|
||||||
width="500px"
|
width="425px"
|
||||||
height="300px"
|
height="275px"
|
||||||
title="Create a channel"
|
title="Create a channel"
|
||||||
alignItems="center"
|
alignItems="center"
|
||||||
onClose={ handleClose }
|
onClose={ handleClose }
|
||||||
|
|
|
@ -10,6 +10,8 @@ export default function ChannelUserButton({ user, subtext }) {
|
||||||
const [userObject, setUserObject] = useState(null);
|
const [userObject, setUserObject] = useState(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (!isPromptOpen) return;
|
||||||
|
if (userObject) return;
|
||||||
authenticated(`/api/v1/users/user/${user._id}/info`, {
|
authenticated(`/api/v1/users/user/${user._id}/info`, {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
|
@ -20,7 +22,7 @@ export default function ChannelUserButton({ user, subtext }) {
|
||||||
setUserObject(json.user);
|
setUserObject(json.user);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, [user]);
|
}, [user, isPromptOpen, userObject]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|
Loading…
Reference in a new issue