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 (
|
||||
_event: Electron.IpcMainInvokeEvent
|
||||
): Promise<FriendRequest[] | null> => {
|
||||
return HydraApi.get(`/profile/friend-requests`).catch(() => null);
|
||||
): Promise<FriendRequest[]> => {
|
||||
return HydraApi.get(`/profile/friend-requests`).catch(() => []);
|
||||
};
|
||||
|
||||
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,
|
||||
newProfileImagePath: string | null
|
||||
) => Promise<UserProfile>;
|
||||
getFriendRequests: () => Promise<FriendRequest[] | null>;
|
||||
getFriendRequests: () => Promise<FriendRequest[]>;
|
||||
updateFriendRequest: (
|
||||
userId: string,
|
||||
action: FriendRequestAction
|
||||
|
@ -91,7 +91,7 @@ export function useUserDetails() {
|
||||
|
||||
const updateFriendRequests = useCallback(async () => {
|
||||
const friendRequests = await window.electron.getFriendRequests();
|
||||
dispatch(setFriendRequests(friendRequests || []));
|
||||
dispatch(setFriendRequests(friendRequests));
|
||||
}, [dispatch]);
|
||||
|
||||
const showFriendsModal = useCallback(
|
||||
|
@ -119,7 +119,7 @@ export const UserFriendModalAddFriend = ({
|
||||
}}
|
||||
>
|
||||
<h3>Pendentes</h3>
|
||||
{friendRequests?.map((request) => {
|
||||
{friendRequests.map((request) => {
|
||||
return (
|
||||
<UserFriendRequest
|
||||
key={request.id}
|
||||
|
@ -224,7 +224,7 @@ export function UserContent({
|
||||
<div className={styles.profileGameSection}>
|
||||
<h2>{t("activity")}</h2>
|
||||
|
||||
{!userProfile.recentGames?.length ? (
|
||||
{!userProfile.recentGames.length ? (
|
||||
<div className={styles.noDownloads}>
|
||||
<div className={styles.telescopeIcon}>
|
||||
<TelescopeIcon size={24} />
|
||||
@ -295,7 +295,7 @@ export function UserContent({
|
||||
}}
|
||||
/>
|
||||
<h3 style={{ fontWeight: "400" }}>
|
||||
{userProfile.libraryGames?.length}
|
||||
{userProfile.libraryGames.length}
|
||||
</h3>
|
||||
</div>
|
||||
<small>{t("total_play_time", { amount: formatPlayTime() })}</small>
|
||||
@ -306,7 +306,7 @@ export function UserContent({
|
||||
gap: `${SPACING_UNIT}px`,
|
||||
}}
|
||||
>
|
||||
{userProfile.libraryGames?.map((game) => (
|
||||
{userProfile.libraryGames.map((game) => (
|
||||
<button
|
||||
key={game.objectID}
|
||||
className={cn(styles.gameListItem, styles.profileContentBox)}
|
||||
@ -344,7 +344,7 @@ export function UserContent({
|
||||
}}
|
||||
/>
|
||||
<h3 style={{ fontWeight: "400" }}>
|
||||
{userProfile.friends?.length || 0}
|
||||
{userProfile.friends.length}
|
||||
</h3>
|
||||
</button>
|
||||
|
||||
@ -355,7 +355,7 @@ export function UserContent({
|
||||
gap: `${SPACING_UNIT}px`,
|
||||
}}
|
||||
>
|
||||
{userProfile.friends?.map((friend) => {
|
||||
{userProfile.friends.map((friend) => {
|
||||
return (
|
||||
<button
|
||||
key={friend.id}
|
||||
|
@ -289,9 +289,9 @@ export interface UserProfile {
|
||||
displayName: string;
|
||||
profileImageUrl: string | null;
|
||||
totalPlayTimeInSeconds: number;
|
||||
libraryGames: UserGame[] | null;
|
||||
recentGames: UserGame[] | null;
|
||||
friends: UserFriend[] | null;
|
||||
libraryGames: UserGame[];
|
||||
recentGames: UserGame[];
|
||||
friends: UserFriend[];
|
||||
}
|
||||
|
||||
export interface DownloadSource {
|
||||
|
Loading…
Reference in New Issue
Block a user