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