Skip to content

Commit

Permalink
feat: remove nullables
Browse files Browse the repository at this point in the history
  • Loading branch information
zamitto committed Jul 17, 2024
1 parent 8c67dda commit 929be48
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/main/events/profile/get-friend-requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 1 addition & 1 deletion src/renderer/src/declaration.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/hooks/use-user-details.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export const UserFriendModalAddFriend = ({
}}
>
<h3>Pendentes</h3>
{friendRequests?.map((request) => {
{friendRequests.map((request) => {
return (
<UserFriendRequest
key={request.id}
Expand Down
10 changes: 5 additions & 5 deletions src/renderer/src/pages/user/user-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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} />
Expand Down Expand Up @@ -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>
Expand All @@ -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)}
Expand Down Expand Up @@ -344,7 +344,7 @@ export function UserContent({
}}
/>
<h3 style={{ fontWeight: "400" }}>
{userProfile.friends?.length || 0}
{userProfile.friends.length}
</h3>
</button>

Expand All @@ -355,7 +355,7 @@ export function UserContent({
gap: `${SPACING_UNIT}px`,
}}
>
{userProfile.friends?.map((friend) => {
{userProfile.friends.map((friend) => {
return (
<button
key={friend.id}
Expand Down
6 changes: 3 additions & 3 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 929be48

Please sign in to comment.