diff --git a/src/App.svelte b/src/App.svelte index d938601..8465c32 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -60,6 +60,10 @@ let oauthIdentity: 'streamer' | 'bot' = 'streamer'; let oauthBusy = false; let oauthError = ''; + let oauthScopes: Record<'streamer' | 'bot', { connected: boolean; missing_scopes: string[]; reauthorization_required: boolean }> = { + streamer: { connected: false, missing_scopes: [], reauthorization_required: false }, + bot: { connected: false, missing_scopes: [], reauthorization_required: false }, + }; async function checkServer() { connectionState = 'CONNECTING'; @@ -106,6 +110,7 @@ await loadActivity(); await loadNotifications(); await loadDiagnostics(); + await loadOAuthStatus(); await loadCollaboration(); await loadStreamInfo(); connectRealtime(); @@ -491,6 +496,21 @@ } } + async function loadOAuthStatus() { + for (const identity of ['streamer', 'bot'] as const) { + try { + const response = await fetch(`${serverAddress}/api/v1/twitch/oauth/status?identity=${identity}`, { + headers: { authorization: `Bearer ${sessionToken}` }, + }); + if (!response.ok) continue; + const result = await response.json(); + oauthScopes = { ...oauthScopes, [identity]: result }; + } catch { + // The diagnostics panel remains usable if scope status is temporarily unavailable. + } + } + } + async function revokeOAuth(identity: 'streamer' | 'bot') { oauthBusy = true; oauthError = ''; @@ -500,6 +520,7 @@ headers: { authorization: `Bearer ${sessionToken}` }, }); if (!response.ok) throw new Error('The server could not revoke this Twitch authorization.'); + await loadOAuthStatus(); await loadStreamInfo(); } catch (error) { oauthError = error instanceof Error ? error.message : 'The Twitch authorization could not be revoked.'; @@ -561,6 +582,13 @@ + + +