mirror of
https://github.com/Andre-Bzk/twitch4steamdeck.git
synced 2026-11-15 15:43:08 +01:00
Fix: Sidebar Darstellung korrigert
- Zusätzlich Menueinträge Top Streams - Topstreams DE und EN anzeige filterte Livestreams. - Einstellung Sidebarbreite und Flaggenbadge (Slider) hinzugefügt.
This commit is contained in:
@@ -60,7 +60,13 @@ export function registerIpcHandlers(
|
||||
)
|
||||
ipcMain.handle(
|
||||
IPC.twitchGetTopStreams,
|
||||
(_e, gameId?: string) => helix.getTopStreams(gameId ? { gameId, limit: 40 } : { limit: 100 })
|
||||
(_e, options?: { gameId?: string; language?: string; cursor?: string; limit?: number }) =>
|
||||
helix.getTopStreams({
|
||||
gameId: options?.gameId,
|
||||
language: options?.language,
|
||||
cursor: options?.cursor,
|
||||
limit: options?.limit ?? (options?.gameId ? 40 : 100)
|
||||
})
|
||||
)
|
||||
ipcMain.handle(
|
||||
IPC.twitchGetVideos,
|
||||
|
||||
@@ -5,6 +5,7 @@ import type {
|
||||
HelixGame,
|
||||
HelixPaginatedResponse,
|
||||
HelixStream,
|
||||
TopStreamsResult,
|
||||
HelixUser,
|
||||
HelixVideo,
|
||||
VodChapter,
|
||||
@@ -168,9 +169,16 @@ export class HelixClient {
|
||||
}
|
||||
}
|
||||
|
||||
async getTopStreams(opts?: { gameId?: string; limit?: number }): Promise<FollowedChannelInfo[]> {
|
||||
async getTopStreams(opts?: {
|
||||
gameId?: string
|
||||
language?: string
|
||||
limit?: number
|
||||
cursor?: string
|
||||
}): Promise<TopStreamsResult> {
|
||||
const params: Record<string, string> = { first: String(opts?.limit ?? 20) }
|
||||
if (opts?.gameId) params.game_id = opts.gameId
|
||||
if (opts?.language) params.language = opts.language
|
||||
if (opts?.cursor) params.after = opts.cursor
|
||||
|
||||
const url = new URL(`${BASE}/streams`)
|
||||
for (const [k, v] of Object.entries(params)) url.searchParams.set(k, v)
|
||||
@@ -179,13 +187,14 @@ export class HelixClient {
|
||||
const body = await res.text().catch(() => '')
|
||||
throw new Error(`Helix /streams → ${res.status}: ${body}`)
|
||||
}
|
||||
const data = (await res.json()) as { data: HelixStream[] }
|
||||
const data = (await res.json()) as HelixPaginatedResponse<HelixStream>
|
||||
const streams = data.data
|
||||
|
||||
const userIds = streams.map((s) => s.user_id)
|
||||
const avatarMap = await this.getProfileImages(userIds)
|
||||
|
||||
return streams.map((s) => ({
|
||||
return {
|
||||
streams: streams.map((s) => ({
|
||||
broadcasterId: s.user_id,
|
||||
broadcasterLogin: s.user_login,
|
||||
broadcasterName: s.user_name,
|
||||
@@ -198,7 +207,9 @@ export class HelixClient {
|
||||
thumbnailUrl: s.thumbnail_url.replace('{width}', '440').replace('{height}', '248'),
|
||||
startedAt: s.started_at,
|
||||
language: s.language
|
||||
}))
|
||||
})),
|
||||
cursor: data.pagination?.cursor
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly GQL_URL = 'https://gql.twitch.tv/gql'
|
||||
|
||||
@@ -91,3 +91,8 @@ export interface FollowedChannelInfo {
|
||||
startedAt?: string
|
||||
language?: string
|
||||
}
|
||||
|
||||
export interface TopStreamsResult {
|
||||
streams: FollowedChannelInfo[]
|
||||
cursor?: string
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user