feat: remove nullables

This commit is contained in:
Zamitto 2024-07-17 19:03:32 -03:00
parent 8c67dda84e
commit 929be48495
6 changed files with 13 additions and 13 deletions

View File

@ -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);

View File

@ -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

View File

@ -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(

View File

@ -119,7 +119,7 @@ export const UserFriendModalAddFriend = ({
}}
>
<h3>Pendentes</h3>
{friendRequests?.map((request) => {
{friendRequests.map((request) => {
return (
<UserFriendRequest
key={request.id}

View File

@ -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}

View File

@ -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 {