mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-01-23 21:44:55 +03:00
feat: rename functions
This commit is contained in:
parent
6b8f2e6978
commit
e642bf71b1
@ -42,7 +42,7 @@ export function App() {
|
|||||||
const {
|
const {
|
||||||
isFriendsModalVisible,
|
isFriendsModalVisible,
|
||||||
friendRequetsModalTab,
|
friendRequetsModalTab,
|
||||||
updateFriendRequests,
|
fetchFriendRequests,
|
||||||
hideFriendsModal,
|
hideFriendsModal,
|
||||||
} = useUserDetails();
|
} = useUserDetails();
|
||||||
|
|
||||||
@ -104,7 +104,7 @@ export function App() {
|
|||||||
fetchUserDetails().then((response) => {
|
fetchUserDetails().then((response) => {
|
||||||
if (response) {
|
if (response) {
|
||||||
updateUserDetails(response);
|
updateUserDetails(response);
|
||||||
updateFriendRequests();
|
fetchFriendRequests();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, [fetchUserDetails, updateUserDetails, dispatch]);
|
}, [fetchUserDetails, updateUserDetails, dispatch]);
|
||||||
@ -113,7 +113,7 @@ export function App() {
|
|||||||
fetchUserDetails().then((response) => {
|
fetchUserDetails().then((response) => {
|
||||||
if (response) {
|
if (response) {
|
||||||
updateUserDetails(response);
|
updateUserDetails(response);
|
||||||
updateFriendRequests();
|
fetchFriendRequests();
|
||||||
showSuccessToast(t("successfully_signed_in"));
|
showSuccessToast(t("successfully_signed_in"));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -84,7 +84,7 @@ export function useUserDetails() {
|
|||||||
[updateUserDetails]
|
[updateUserDetails]
|
||||||
);
|
);
|
||||||
|
|
||||||
const updateFriendRequests = useCallback(async () => {
|
const fetchFriendRequests = useCallback(async () => {
|
||||||
const friendRequests = await window.electron.getFriendRequests();
|
const friendRequests = await window.electron.getFriendRequests();
|
||||||
dispatch(setFriendRequests(friendRequests));
|
dispatch(setFriendRequests(friendRequests));
|
||||||
}, [dispatch]);
|
}, [dispatch]);
|
||||||
@ -92,7 +92,7 @@ export function useUserDetails() {
|
|||||||
const showFriendsModal = useCallback(
|
const showFriendsModal = useCallback(
|
||||||
(tab: UserFriendModalTab) => {
|
(tab: UserFriendModalTab) => {
|
||||||
dispatch(setFriendsModalVisible(tab));
|
dispatch(setFriendsModalVisible(tab));
|
||||||
updateFriendRequests();
|
fetchFriendRequests();
|
||||||
},
|
},
|
||||||
[dispatch]
|
[dispatch]
|
||||||
);
|
);
|
||||||
@ -105,18 +105,18 @@ export function useUserDetails() {
|
|||||||
async (userId: string) => {
|
async (userId: string) => {
|
||||||
return window.electron
|
return window.electron
|
||||||
.sendFriendRequest(userId)
|
.sendFriendRequest(userId)
|
||||||
.then(() => updateFriendRequests());
|
.then(() => fetchFriendRequests());
|
||||||
},
|
},
|
||||||
[updateFriendRequests]
|
[fetchFriendRequests]
|
||||||
);
|
);
|
||||||
|
|
||||||
const updateFriendRequestState = useCallback(
|
const updateFriendRequestState = useCallback(
|
||||||
async (userId: string, action: FriendRequestAction) => {
|
async (userId: string, action: FriendRequestAction) => {
|
||||||
return window.electron
|
return window.electron
|
||||||
.updateFriendRequest(userId, action)
|
.updateFriendRequest(userId, action)
|
||||||
.then(() => updateFriendRequests());
|
.then(() => fetchFriendRequests());
|
||||||
},
|
},
|
||||||
[updateFriendRequests]
|
[fetchFriendRequests]
|
||||||
);
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -133,7 +133,7 @@ export function useUserDetails() {
|
|||||||
updateUserDetails,
|
updateUserDetails,
|
||||||
patchUser,
|
patchUser,
|
||||||
sendFriendRequest,
|
sendFriendRequest,
|
||||||
updateFriendRequests,
|
fetchFriendRequests,
|
||||||
updateFriendRequestState,
|
updateFriendRequestState,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -56,19 +56,19 @@ export const UserFriendModalAddFriend = ({
|
|||||||
navigate(`/user/${friendCode}`);
|
navigate(`/user/${friendCode}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleClickCancelFriendRequest = (userId: string) => {
|
const handleCancelFriendRequest = (userId: string) => {
|
||||||
updateFriendRequestState(userId, "CANCEL").catch(() => {
|
updateFriendRequestState(userId, "CANCEL").catch(() => {
|
||||||
showErrorToast("Falha ao cancelar convite");
|
showErrorToast("Falha ao cancelar convite");
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleClickAcceptFriendRequest = (userId: string) => {
|
const handleAcceptFriendRequest = (userId: string) => {
|
||||||
updateFriendRequestState(userId, "ACCEPTED").catch(() => {
|
updateFriendRequestState(userId, "ACCEPTED").catch(() => {
|
||||||
showErrorToast("Falha ao aceitar convite");
|
showErrorToast("Falha ao aceitar convite");
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleClickRefuseFriendRequest = (userId: string) => {
|
const handleRefuseFriendRequest = (userId: string) => {
|
||||||
updateFriendRequestState(userId, "REFUSED").catch(() => {
|
updateFriendRequestState(userId, "REFUSED").catch(() => {
|
||||||
showErrorToast("Falha ao recusar convite");
|
showErrorToast("Falha ao recusar convite");
|
||||||
});
|
});
|
||||||
@ -127,9 +127,9 @@ export const UserFriendModalAddFriend = ({
|
|||||||
isRequestSent={request.type === "SENT"}
|
isRequestSent={request.type === "SENT"}
|
||||||
profileImageUrl={request.profileImageUrl}
|
profileImageUrl={request.profileImageUrl}
|
||||||
userId={request.id}
|
userId={request.id}
|
||||||
onClickAcceptRequest={handleClickAcceptFriendRequest}
|
onClickAcceptRequest={handleAcceptFriendRequest}
|
||||||
onClickCancelRequest={handleClickCancelFriendRequest}
|
onClickCancelRequest={handleCancelFriendRequest}
|
||||||
onClickRefuseRequest={handleClickRefuseFriendRequest}
|
onClickRefuseRequest={handleRefuseFriendRequest}
|
||||||
onClickRequest={handleClickRequest}
|
onClickRequest={handleClickRequest}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
@ -47,10 +47,11 @@ export function UserContent({
|
|||||||
profileBackground,
|
profileBackground,
|
||||||
friendRequests,
|
friendRequests,
|
||||||
signOut,
|
signOut,
|
||||||
updateFriendRequests,
|
fetchFriendRequests,
|
||||||
showFriendsModal,
|
showFriendsModal,
|
||||||
|
updateFriendRequestState,
|
||||||
} = useUserDetails();
|
} = useUserDetails();
|
||||||
const { showSuccessToast } = useToast();
|
const { showSuccessToast, showErrorToast } = useToast();
|
||||||
|
|
||||||
const [profileContentBoxBackground, setProfileContentBoxBackground] =
|
const [profileContentBoxBackground, setProfileContentBoxBackground] =
|
||||||
useState<string | undefined>();
|
useState<string | undefined>();
|
||||||
@ -106,7 +107,7 @@ export function UserContent({
|
|||||||
const isMe = userDetails?.id == userProfile.id;
|
const isMe = userDetails?.id == userProfile.id;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isMe) updateFriendRequests();
|
if (isMe) fetchFriendRequests();
|
||||||
}, [isMe]);
|
}, [isMe]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -123,6 +124,24 @@ export function UserContent({
|
|||||||
}
|
}
|
||||||
}, [profileBackground, isMe]);
|
}, [profileBackground, isMe]);
|
||||||
|
|
||||||
|
const handleCancelFriendRequest = (userId: string) => {
|
||||||
|
updateFriendRequestState(userId, "CANCEL").catch(() => {
|
||||||
|
showErrorToast("Falha ao cancelar convite");
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleAcceptFriendRequest = (userId: string) => {
|
||||||
|
updateFriendRequestState(userId, "ACCEPTED").catch(() => {
|
||||||
|
showErrorToast("Falha ao aceitar convite");
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleRefuseFriendRequest = (userId: string) => {
|
||||||
|
updateFriendRequestState(userId, "REFUSED").catch(() => {
|
||||||
|
showErrorToast("Falha ao recusar convite");
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const getProfileActions = () => {
|
const getProfileActions = () => {
|
||||||
if (isMe) {
|
if (isMe) {
|
||||||
return (
|
return (
|
||||||
@ -162,14 +181,14 @@ export function UserContent({
|
|||||||
<Button
|
<Button
|
||||||
theme="outline"
|
theme="outline"
|
||||||
className={styles.acceptRequestButton}
|
className={styles.acceptRequestButton}
|
||||||
onClick={() => {}}
|
onClick={() => handleAcceptFriendRequest(friendRequest.id)}
|
||||||
>
|
>
|
||||||
<CheckCircleIcon size={28} /> {t("accept_request")}
|
<CheckCircleIcon size={28} /> {t("accept_request")}
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
theme="outline"
|
theme="outline"
|
||||||
className={styles.cancelRequestButton}
|
className={styles.cancelRequestButton}
|
||||||
onClick={() => {}}
|
onClick={() => handleRefuseFriendRequest(friendRequest.id)}
|
||||||
>
|
>
|
||||||
<XCircleIcon size={28} /> {t("ignore_request")}
|
<XCircleIcon size={28} /> {t("ignore_request")}
|
||||||
</Button>
|
</Button>
|
||||||
@ -181,7 +200,7 @@ export function UserContent({
|
|||||||
<Button
|
<Button
|
||||||
theme="outline"
|
theme="outline"
|
||||||
className={styles.cancelRequestButton}
|
className={styles.cancelRequestButton}
|
||||||
onClick={() => {}}
|
onClick={() => handleCancelFriendRequest(friendRequest.id)}
|
||||||
>
|
>
|
||||||
<XCircleIcon size={28} /> {t("cancel_request")}
|
<XCircleIcon size={28} /> {t("cancel_request")}
|
||||||
</Button>
|
</Button>
|
||||||
|
Loading…
Reference in New Issue
Block a user