fix: request to get user setting if no token exists

This commit is contained in:
Kentai Radiquum 2025-03-22 00:40:55 +05:00
parent 43d3aab01d
commit 19dbd69fd5
Signed by: Radiquum
GPG key ID: 858E8EE696525EED

View file

@ -62,6 +62,10 @@ export const ProfileEditModal = (props: {
}; };
function useFetchInfo(url: string) { function useFetchInfo(url: string) {
if (!props.token) {
url = "";
}
const { data, isLoading, error } = useSWR(url, useSWRfetcher); const { data, isLoading, error } = useSWR(url, useSWRfetcher);
return [data, isLoading, error]; return [data, isLoading, error];
} }
@ -184,6 +188,10 @@ export const ProfileEditModal = (props: {
} }
}, [avatarModalProps.croppedImage]); }, [avatarModalProps.croppedImage]);
if (!prefData || !loginData || prefError || loginError) {
return <></>;
}
return ( return (
<> <>
<Modal <Modal
@ -381,46 +389,50 @@ export const ProfileEditModal = (props: {
} }
</Modal.Body> </Modal.Body>
</Modal> </Modal>
<ProfileEditPrivacyModal {props.token ?
isOpen={privacyModalOpen} <>
setIsOpen={setPrivacyModalOpen} <ProfileEditPrivacyModal
token={props.token} isOpen={privacyModalOpen}
setting={privacyModalSetting} setIsOpen={setPrivacyModalOpen}
privacySettings={privacySettings} token={props.token}
setPrivacySettings={setPrivacySettings} setting={privacyModalSetting}
/> privacySettings={privacySettings}
<ProfileEditStatusModal setPrivacySettings={setPrivacySettings}
isOpen={statusModalOpen} />
setIsOpen={setStatusModalOpen} <ProfileEditStatusModal
token={props.token} isOpen={statusModalOpen}
status={status} setIsOpen={setStatusModalOpen}
setStatus={setStatus} token={props.token}
profile_id={props.profile_id} status={status}
/> setStatus={setStatus}
<ProfileEditSocialModal profile_id={props.profile_id}
isOpen={socialModalOpen} />
setIsOpen={setSocialModalOpen} <ProfileEditSocialModal
token={props.token} isOpen={socialModalOpen}
profile_id={props.profile_id} setIsOpen={setSocialModalOpen}
/> token={props.token}
<CropModal profile_id={props.profile_id}
{...avatarModalProps} />
cropParams={{ <CropModal
aspectRatio: 1 / 1, {...avatarModalProps}
forceAspect: true, cropParams={{
guides: true, aspectRatio: 1 / 1,
width: 600, forceAspect: true,
height: 600, guides: true,
}} width: 600,
setCropModalProps={setAvatarModalProps} height: 600,
/> }}
<ProfileEditLoginModal setCropModalProps={setAvatarModalProps}
isOpen={loginModalOpen} />
setIsOpen={setLoginModalOpen} <ProfileEditLoginModal
token={props.token} isOpen={loginModalOpen}
setLogin={setLogin} setIsOpen={setLoginModalOpen}
profile_id={props.profile_id} token={props.token}
/> setLogin={setLogin}
profile_id={props.profile_id}
/>
</>
: ""}
</> </>
); );
}; };