From f93b07c87a041e910cf06dd9d3e1447245af94ea Mon Sep 17 00:00:00 2001 From: xRangerDE Date: Mon, 11 May 2026 01:46:13 +0200 Subject: [PATCH] cleanup: remove dead fetchOnlyFollowerCount + clarify profile inferred type Two related artifacts left over from the avatar/banner GQL refactor in 4.6.20: - fetchOnlyFollowerCount was an early standalone helper from the iteration where Helix supplied core profile fields and a separate public-GQL roundtrip pulled just the follower count. The 4.6.19 rewrite folded all of that into a single public-GQL query, so the helper has no callers. Removed. - streamFromPublic was typed via `Awaited> extends ...` conditional inference because the inline stream shape was anonymous. That worked but read like a riddle. Hoisted the inline shapes to two named interfaces (PublicStreamInfo + PublicStreamerProfileResult) so the function signature is explicit and the local var is just `PublicStreamInfo | null`. Same type, an order of magnitude more obvious to anyone reading. Both changes are zero-runtime-behavior; tests confirm. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/main.ts | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/main.ts b/src/main.ts index 7ebaf6e..aa150f1 100644 --- a/src/main.ts +++ b/src/main.ts @@ -2410,15 +2410,24 @@ interface PublicProfileQueryResult { } | null; } -async function fetchPublicStreamerProfile(login: string): Promise<{ +interface PublicStreamerProfileResult { displayName: string; avatarUrl: string; bannerUrl: string; description: string; broadcasterType: '' | 'partner' | 'affiliate'; followerCount: number | null; - stream: { previewUrl: string; viewers: number | null; title: string | null; game: string | null } | null; -} | null> { + stream: PublicStreamInfo | null; +} + +interface PublicStreamInfo { + previewUrl: string; + viewers: number | null; + title: string | null; + game: string | null; +} + +async function fetchPublicStreamerProfile(login: string): Promise { // Same query also pulls bannerImageURL and the current stream's // preview + viewer count when live — saves a separate roundtrip. const data = await fetchPublicTwitchGql( @@ -2467,15 +2476,6 @@ async function fetchPublicStreamerProfile(login: string): Promise<{ }; } -async function fetchOnlyFollowerCount(login: string): Promise { - const data = await fetchPublicTwitchGql( - `query($login: String!) { user(login: $login) { followers { totalCount } } }`, - { login } - ); - const cnt = data?.user?.followers?.totalCount; - return typeof cnt === 'number' ? cnt : null; -} - async function getStreamerProfile(login: string, forceRefresh = false): Promise { const normalized = normalizeLogin(login); if (!normalized) return null; @@ -2502,7 +2502,7 @@ async function getStreamerProfile(login: string, forceRefresh = false): Promise< let bannerUrl = ''; let description = ''; let broadcasterType: '' | 'partner' | 'affiliate' = ''; - let streamFromPublic: Awaited> extends infer R ? (R extends null ? null : R extends { stream: infer S } ? S : null) : null = null; + let streamFromPublic: PublicStreamInfo | null = null; let followerCountFromPublic: number | null = null; const publicProfile = await fetchPublicStreamerProfile(normalized);