Skip to content
This repository has been archived by the owner on Feb 7, 2024. It is now read-only.

Mark userId nullable (Breaking Change) #85

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/methods/findById.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { getURL, getAvatars } from '../utils';

export interface IProfile {
profileId: UUID;
userId: UUID;
userId: UUID | null;
idOnPlatform: UUID | string;
platformType: PlatformAllExtended;
nameOnPlatform: string;
Expand Down
2 changes: 1 addition & 1 deletion src/methods/findByUsername.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { getURL, getAvatars } from '../utils';

export interface IProfile {
profileId: UUID;
userId: UUID;
userId: UUID | null;
idOnPlatform: UUID | string;
platformType: PlatformAll;
nameOnPlatform: string;
Expand Down
8 changes: 5 additions & 3 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ import {
STATS_CATEGORIES, GITHUB_ASSETS_URL
} from './constants';

export const getAvatarURL = (id: UUID, size = 256) =>
`${AVATARS_URL}/${id}/default_${size === 500 ? 'tall' : `${size}_${size}`}.png`;
export const getAvatarURL = (id: UUID | null, size = 256) =>
id
BadCoder1337 marked this conversation as resolved.
Show resolved Hide resolved
? `${AVATARS_URL}/${id}/default_${size === 500 ? 'tall' : `${size}_${size}`}.png`
: `${AVATARS_URL}/default_${size === 500 ? 'tall' : `${size}_${size}`}.png`;

export const getAvatars = (id: UUID) => ({
export const getAvatars = (id: UUID | null) => ({
146: getAvatarURL(id, 146), 256: getAvatarURL(id, 256), 500: getAvatarURL(id, 500)
});

Expand Down