mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-01-23 21:44:55 +03:00
feat: adjust ui
This commit is contained in:
parent
fbe3c1973a
commit
80123d67e1
@ -267,6 +267,7 @@
|
|||||||
"private": "Private",
|
"private": "Private",
|
||||||
"friends_only": "Friends only",
|
"friends_only": "Friends only",
|
||||||
"privacy": "Privacy",
|
"privacy": "Privacy",
|
||||||
"blocked_users": "Blocked users"
|
"blocked_users": "Blocked users",
|
||||||
|
"unblock": "Unblock"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -267,6 +267,7 @@
|
|||||||
"private": "Privado",
|
"private": "Privado",
|
||||||
"friends_only": "Apenas amigos",
|
"friends_only": "Apenas amigos",
|
||||||
"public": "Público",
|
"public": "Público",
|
||||||
"blocked_users": "Usuários bloqueados"
|
"blocked_users": "Usuários bloqueados",
|
||||||
|
"unblock": "Desbloquear"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ export function App() {
|
|||||||
fetchFriendRequests();
|
fetchFriendRequests();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, [fetchUserDetails, updateUserDetails, dispatch]);
|
}, [fetchUserDetails, fetchFriendRequests, updateUserDetails, dispatch]);
|
||||||
|
|
||||||
const onSignIn = useCallback(() => {
|
const onSignIn = useCallback(() => {
|
||||||
fetchUserDetails().then((response) => {
|
fetchUserDetails().then((response) => {
|
||||||
@ -118,7 +118,13 @@ export function App() {
|
|||||||
showSuccessToast(t("successfully_signed_in"));
|
showSuccessToast(t("successfully_signed_in"));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, [fetchUserDetails, t, showSuccessToast, updateUserDetails]);
|
}, [
|
||||||
|
fetchUserDetails,
|
||||||
|
fetchFriendRequests,
|
||||||
|
t,
|
||||||
|
showSuccessToast,
|
||||||
|
updateUserDetails,
|
||||||
|
]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const unsubscribe = window.electron.onGamesRunning((gamesRunning) => {
|
const unsubscribe = window.electron.onGamesRunning((gamesRunning) => {
|
||||||
|
@ -99,7 +99,7 @@ export function useUserDetails() {
|
|||||||
dispatch(setFriendsModalVisible({ initialTab, userId }));
|
dispatch(setFriendsModalVisible({ initialTab, userId }));
|
||||||
fetchFriendRequests();
|
fetchFriendRequests();
|
||||||
},
|
},
|
||||||
[dispatch]
|
[dispatch, fetchFriendRequests]
|
||||||
);
|
);
|
||||||
|
|
||||||
const hideFriendsModal = useCallback(() => {
|
const hideFriendsModal = useCallback(() => {
|
||||||
|
@ -12,21 +12,26 @@ export type UserFriendItemProps = {
|
|||||||
userId: string;
|
userId: string;
|
||||||
profileImageUrl: string | null;
|
profileImageUrl: string | null;
|
||||||
displayName: string;
|
displayName: string;
|
||||||
onClickItem: (userId: string) => void;
|
|
||||||
} & (
|
} & (
|
||||||
| { type: "ACCEPTED"; onClickUndoFriendship: (userId: string) => void }
|
| {
|
||||||
|
type: "ACCEPTED";
|
||||||
|
onClickUndoFriendship: (userId: string) => void;
|
||||||
|
onClickItem: (userId: string) => void;
|
||||||
|
}
|
||||||
|
| { type: "BLOCKED"; onClickUnblock: (userId: string) => void }
|
||||||
| {
|
| {
|
||||||
type: "SENT" | "RECEIVED";
|
type: "SENT" | "RECEIVED";
|
||||||
onClickCancelRequest: (userId: string) => void;
|
onClickCancelRequest: (userId: string) => void;
|
||||||
onClickAcceptRequest: (userId: string) => void;
|
onClickAcceptRequest: (userId: string) => void;
|
||||||
onClickRefuseRequest: (userId: string) => void;
|
onClickRefuseRequest: (userId: string) => void;
|
||||||
|
onClickItem: (userId: string) => void;
|
||||||
}
|
}
|
||||||
| { type: null }
|
| { type: null; onClickItem: (userId: string) => void }
|
||||||
);
|
);
|
||||||
|
|
||||||
export const UserFriendItem = (props: UserFriendItemProps) => {
|
export const UserFriendItem = (props: UserFriendItemProps) => {
|
||||||
const { t } = useTranslation("user_profile");
|
const { t } = useTranslation("user_profile");
|
||||||
const { userId, profileImageUrl, displayName, type, onClickItem } = props;
|
const { userId, profileImageUrl, displayName, type } = props;
|
||||||
|
|
||||||
const getRequestDescription = () => {
|
const getRequestDescription = () => {
|
||||||
if (type === "ACCEPTED" || type === null) return null;
|
if (type === "ACCEPTED" || type === null) return null;
|
||||||
@ -86,15 +91,69 @@ export const UserFriendItem = (props: UserFriendItemProps) => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (type === "BLOCKED") {
|
||||||
|
return (
|
||||||
|
<button
|
||||||
|
className={styles.cancelRequestButton}
|
||||||
|
onClick={() => props.onClickUnblock(userId)}
|
||||||
|
title={t("unblock")}
|
||||||
|
>
|
||||||
|
<XCircleIcon size={28} />
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (type === "BLOCKED") {
|
||||||
|
return (
|
||||||
|
<div className={cn(styles.friendListContainer, styles.profileContentBox)}>
|
||||||
|
<div className={styles.friendListButton} style={{ cursor: "inherit" }}>
|
||||||
|
<div className={styles.friendAvatarContainer}>
|
||||||
|
{profileImageUrl ? (
|
||||||
|
<img
|
||||||
|
className={styles.profileAvatar}
|
||||||
|
alt={displayName}
|
||||||
|
src={profileImageUrl}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<PersonIcon size={24} />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
display: "flex",
|
||||||
|
flexDirection: "column",
|
||||||
|
alignItems: "flex-start",
|
||||||
|
flex: "1",
|
||||||
|
minWidth: 0,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<p className={styles.friendListDisplayName}>{displayName}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
position: "absolute",
|
||||||
|
right: "8px",
|
||||||
|
display: "flex",
|
||||||
|
gap: `${SPACING_UNIT}px`,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{getRequestActions()}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={cn(styles.friendListContainer, styles.profileContentBox)}>
|
<div className={cn(styles.friendListContainer, styles.profileContentBox)}>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className={styles.friendListButton}
|
className={styles.friendListButton}
|
||||||
onClick={() => onClickItem(userId)}
|
onClick={() => props.onClickItem(userId)}
|
||||||
>
|
>
|
||||||
<div className={styles.friendAvatarContainer}>
|
<div className={styles.friendAvatarContainer}>
|
||||||
{profileImageUrl ? (
|
{profileImageUrl ? (
|
||||||
|
@ -1,23 +1,15 @@
|
|||||||
import { SPACING_UNIT } from "@renderer/theme.css";
|
import { SPACING_UNIT } from "@renderer/theme.css";
|
||||||
import { UserFriend } from "@types";
|
import { UserFriend } from "@types";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { useNavigate } from "react-router-dom";
|
|
||||||
import { useToast, useUserDetails } from "@renderer/hooks";
|
import { useToast, useUserDetails } from "@renderer/hooks";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { UserFriendItem } from "@renderer/pages/shared-modals/user-friend-modal/user-friend-item";
|
import { UserFriendItem } from "@renderer/pages/shared-modals/user-friend-modal/user-friend-item";
|
||||||
|
|
||||||
export interface UserEditProfileBlockListProps {
|
|
||||||
closeModal: () => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
const pageSize = 12;
|
const pageSize = 12;
|
||||||
|
|
||||||
export const UserEditProfileBlockList = ({
|
export const UserEditProfileBlockList = () => {
|
||||||
closeModal,
|
|
||||||
}: UserEditProfileBlockListProps) => {
|
|
||||||
const { t } = useTranslation("user_profile");
|
const { t } = useTranslation("user_profile");
|
||||||
const { showErrorToast } = useToast();
|
const { showErrorToast } = useToast();
|
||||||
const navigate = useNavigate();
|
|
||||||
|
|
||||||
const [page, setPage] = useState(0);
|
const [page, setPage] = useState(0);
|
||||||
const [maxPage, setMaxPage] = useState(0);
|
const [maxPage, setMaxPage] = useState(0);
|
||||||
@ -51,11 +43,6 @@ export const UserEditProfileBlockList = ({
|
|||||||
reloadList();
|
reloadList();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const handleClickBlocked = (userId: string) => {
|
|
||||||
closeModal();
|
|
||||||
navigate(`/user/${userId}`);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleUnblock = (userId: string) => {
|
const handleUnblock = (userId: string) => {
|
||||||
unblockUser(userId)
|
unblockUser(userId)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
@ -80,9 +67,8 @@ export const UserEditProfileBlockList = ({
|
|||||||
userId={friend.id}
|
userId={friend.id}
|
||||||
displayName={friend.displayName}
|
displayName={friend.displayName}
|
||||||
profileImageUrl={friend.profileImageUrl}
|
profileImageUrl={friend.profileImageUrl}
|
||||||
onClickItem={handleClickBlocked}
|
onClickUnblock={handleUnblock}
|
||||||
onClickUndoFriendship={handleUnblock}
|
type={"BLOCKED"}
|
||||||
type={"ACCEPTED"}
|
|
||||||
key={friend.id}
|
key={friend.id}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
@ -36,7 +36,7 @@ export const UserProfileSettingsModal = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (currentTabIndex == 1) {
|
if (currentTabIndex == 1) {
|
||||||
return <UserEditProfileBlockList closeModal={onClose} />;
|
return <UserEditProfileBlockList />;
|
||||||
}
|
}
|
||||||
|
|
||||||
return <></>;
|
return <></>;
|
||||||
|
Loading…
Reference in New Issue
Block a user