mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-02-03 00:33:49 +03:00
feat: remove nullables
This commit is contained in:
parent
8c67dda84e
commit
929be48495
@ -4,8 +4,8 @@ import { FriendRequest } from "@types";
|
|||||||
|
|
||||||
const getFriendRequests = async (
|
const getFriendRequests = async (
|
||||||
_event: Electron.IpcMainInvokeEvent
|
_event: Electron.IpcMainInvokeEvent
|
||||||
): Promise<FriendRequest[] | null> => {
|
): Promise<FriendRequest[]> => {
|
||||||
return HydraApi.get(`/profile/friend-requests`).catch(() => null);
|
return HydraApi.get(`/profile/friend-requests`).catch(() => []);
|
||||||
};
|
};
|
||||||
|
|
||||||
registerEvent("getFriendRequests", getFriendRequests);
|
registerEvent("getFriendRequests", getFriendRequests);
|
||||||
|
2
src/renderer/src/declaration.d.ts
vendored
2
src/renderer/src/declaration.d.ts
vendored
@ -134,7 +134,7 @@ declare global {
|
|||||||
displayName: string,
|
displayName: string,
|
||||||
newProfileImagePath: string | null
|
newProfileImagePath: string | null
|
||||||
) => Promise<UserProfile>;
|
) => Promise<UserProfile>;
|
||||||
getFriendRequests: () => Promise<FriendRequest[] | null>;
|
getFriendRequests: () => Promise<FriendRequest[]>;
|
||||||
updateFriendRequest: (
|
updateFriendRequest: (
|
||||||
userId: string,
|
userId: string,
|
||||||
action: FriendRequestAction
|
action: FriendRequestAction
|
||||||
|
@ -91,7 +91,7 @@ export function useUserDetails() {
|
|||||||
|
|
||||||
const updateFriendRequests = useCallback(async () => {
|
const updateFriendRequests = useCallback(async () => {
|
||||||
const friendRequests = await window.electron.getFriendRequests();
|
const friendRequests = await window.electron.getFriendRequests();
|
||||||
dispatch(setFriendRequests(friendRequests || []));
|
dispatch(setFriendRequests(friendRequests));
|
||||||
}, [dispatch]);
|
}, [dispatch]);
|
||||||
|
|
||||||
const showFriendsModal = useCallback(
|
const showFriendsModal = useCallback(
|
||||||
|
@ -119,7 +119,7 @@ export const UserFriendModalAddFriend = ({
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<h3>Pendentes</h3>
|
<h3>Pendentes</h3>
|
||||||
{friendRequests?.map((request) => {
|
{friendRequests.map((request) => {
|
||||||
return (
|
return (
|
||||||
<UserFriendRequest
|
<UserFriendRequest
|
||||||
key={request.id}
|
key={request.id}
|
||||||
|
@ -224,7 +224,7 @@ export function UserContent({
|
|||||||
<div className={styles.profileGameSection}>
|
<div className={styles.profileGameSection}>
|
||||||
<h2>{t("activity")}</h2>
|
<h2>{t("activity")}</h2>
|
||||||
|
|
||||||
{!userProfile.recentGames?.length ? (
|
{!userProfile.recentGames.length ? (
|
||||||
<div className={styles.noDownloads}>
|
<div className={styles.noDownloads}>
|
||||||
<div className={styles.telescopeIcon}>
|
<div className={styles.telescopeIcon}>
|
||||||
<TelescopeIcon size={24} />
|
<TelescopeIcon size={24} />
|
||||||
@ -295,7 +295,7 @@ export function UserContent({
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<h3 style={{ fontWeight: "400" }}>
|
<h3 style={{ fontWeight: "400" }}>
|
||||||
{userProfile.libraryGames?.length}
|
{userProfile.libraryGames.length}
|
||||||
</h3>
|
</h3>
|
||||||
</div>
|
</div>
|
||||||
<small>{t("total_play_time", { amount: formatPlayTime() })}</small>
|
<small>{t("total_play_time", { amount: formatPlayTime() })}</small>
|
||||||
@ -306,7 +306,7 @@ export function UserContent({
|
|||||||
gap: `${SPACING_UNIT}px`,
|
gap: `${SPACING_UNIT}px`,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{userProfile.libraryGames?.map((game) => (
|
{userProfile.libraryGames.map((game) => (
|
||||||
<button
|
<button
|
||||||
key={game.objectID}
|
key={game.objectID}
|
||||||
className={cn(styles.gameListItem, styles.profileContentBox)}
|
className={cn(styles.gameListItem, styles.profileContentBox)}
|
||||||
@ -344,7 +344,7 @@ export function UserContent({
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<h3 style={{ fontWeight: "400" }}>
|
<h3 style={{ fontWeight: "400" }}>
|
||||||
{userProfile.friends?.length || 0}
|
{userProfile.friends.length}
|
||||||
</h3>
|
</h3>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
@ -355,7 +355,7 @@ export function UserContent({
|
|||||||
gap: `${SPACING_UNIT}px`,
|
gap: `${SPACING_UNIT}px`,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{userProfile.friends?.map((friend) => {
|
{userProfile.friends.map((friend) => {
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
key={friend.id}
|
key={friend.id}
|
||||||
|
@ -289,9 +289,9 @@ export interface UserProfile {
|
|||||||
displayName: string;
|
displayName: string;
|
||||||
profileImageUrl: string | null;
|
profileImageUrl: string | null;
|
||||||
totalPlayTimeInSeconds: number;
|
totalPlayTimeInSeconds: number;
|
||||||
libraryGames: UserGame[] | null;
|
libraryGames: UserGame[];
|
||||||
recentGames: UserGame[] | null;
|
recentGames: UserGame[];
|
||||||
friends: UserFriend[] | null;
|
friends: UserFriend[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DownloadSource {
|
export interface DownloadSource {
|
||||||
|
Loading…
Reference in New Issue
Block a user