mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
feat: implement undo friendship
This commit is contained in:
parent
edf920fed3
commit
00c46bc981
6 changed files with 25 additions and 2 deletions
1
src/renderer/src/declaration.d.ts
vendored
1
src/renderer/src/declaration.d.ts
vendored
|
@ -138,6 +138,7 @@ declare global {
|
|||
|
||||
/* Profile */
|
||||
getMe: () => Promise<UserProfile | null>;
|
||||
undoFriendship: (userId: string) => Promise<void>;
|
||||
updateProfile: (
|
||||
displayName: string,
|
||||
newProfileImagePath: string | null
|
||||
|
|
|
@ -124,6 +124,10 @@ export function useUserDetails() {
|
|||
[fetchFriendRequests]
|
||||
);
|
||||
|
||||
const undoFriendship = (userId: string) => {
|
||||
return window.electron.undoFriendship(userId);
|
||||
};
|
||||
|
||||
const blockUser = (userId: string) => {
|
||||
return window.electron.blockUser(userId);
|
||||
};
|
||||
|
@ -151,5 +155,6 @@ export function useUserDetails() {
|
|||
updateFriendRequestState,
|
||||
blockUser,
|
||||
unblockUser,
|
||||
undoFriendship,
|
||||
};
|
||||
}
|
||||
|
|
|
@ -50,6 +50,7 @@ export function UserContent({
|
|||
fetchFriendRequests,
|
||||
showFriendsModal,
|
||||
updateFriendRequestState,
|
||||
undoFriendship,
|
||||
blockUser,
|
||||
} = useUserDetails();
|
||||
const { showSuccessToast, showErrorToast } = useToast();
|
||||
|
@ -127,9 +128,11 @@ export function UserContent({
|
|||
|
||||
const handleUndoFriendship = (userRelation: UserRelation) => {
|
||||
const userId =
|
||||
userRelation.AId === userProfile.id ? userRelation.BId : userRelation.AId;
|
||||
userRelation.AId === userDetails?.id
|
||||
? userRelation.BId
|
||||
: userRelation.AId;
|
||||
|
||||
updateFriendRequestState(userId, "CANCEL")
|
||||
undoFriendship(userId)
|
||||
.then(updateUserProfile)
|
||||
.catch(() => {
|
||||
showErrorToast(t("try_again"));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue