From 94e516e5e39c768f370782e31fbfd588831cc7b1 Mon Sep 17 00:00:00 2001 From: BadCoder1337 Date: Mon, 20 Jun 2022 22:32:42 +0300 Subject: [PATCH 1/3] Mark userId nullable --- src/methods/findById.ts | 2 +- src/methods/findByUsername.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/methods/findById.ts b/src/methods/findById.ts index 1ac9c09..49ea9e3 100644 --- a/src/methods/findById.ts +++ b/src/methods/findById.ts @@ -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; diff --git a/src/methods/findByUsername.ts b/src/methods/findByUsername.ts index 95d6804..799fecf 100644 --- a/src/methods/findByUsername.ts +++ b/src/methods/findByUsername.ts @@ -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; From c04ef1e13eabbfbbe2f8787c7966323b577cc3f3 Mon Sep 17 00:00:00 2001 From: BadCoder1337 Date: Mon, 20 Jun 2022 22:46:49 +0300 Subject: [PATCH 2/3] Return generic avatar nulled userId --- src/utils.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index 5fb7633..c844976 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -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 + ? `${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) }); From 712e81e8b228c7fed797f18f2dad2cfdeebe7a60 Mon Sep 17 00:00:00 2001 From: BadCoder1337 Date: Tue, 21 Jun 2022 13:37:13 +0300 Subject: [PATCH 3/3] Return avatar URL with null in path --- src/utils.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index c844976..121c51e 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -14,9 +14,7 @@ import { } from './constants'; export const getAvatarURL = (id: UUID | null, size = 256) => - id - ? `${AVATARS_URL}/${id}/default_${size === 500 ? 'tall' : `${size}_${size}`}.png` - : `${AVATARS_URL}/default_${size === 500 ? 'tall' : `${size}_${size}`}.png`; + `${AVATARS_URL}/${id}/default_${size === 500 ? 'tall' : `${size}_${size}`}.png`; export const getAvatars = (id: UUID | null) => ({ 146: getAvatarURL(id, 146), 256: getAvatarURL(id, 256), 500: getAvatarURL(id, 500)