load collaboration favorites

This commit is contained in:
2026-10-25 05:24:56 +01:00
parent 209f2ed7e0
commit 8b8ba4b618
+18
View File
@@ -59,6 +59,7 @@
let collaborationError = ''; let collaborationError = '';
let showCollaboration = false; let showCollaboration = false;
let collaborationGuestId = ''; let collaborationGuestId = '';
let collaborators: Array<{ twitch_user_id: string; display_name: string; favorite: boolean; last_invited_at: string | null }> = [];
let sharedChatSession: { session_id: string; host_broadcaster_id: string; participants: Array<{ broadcaster_id: string }> } | null = null; let sharedChatSession: { session_id: string; host_broadcaster_id: string; participants: Array<{ broadcaster_id: string }> } | null = null;
let oauthLink = ''; let oauthLink = '';
let oauthIdentity: 'streamer' | 'bot' = 'streamer'; let oauthIdentity: 'streamer' | 'bot' = 'streamer';
@@ -134,6 +135,7 @@
await loadDiagnostics(); await loadDiagnostics();
await loadOAuthStatus(); await loadOAuthStatus();
await loadCollaboration(); await loadCollaboration();
await loadCollaborators();
await loadBotCommands(); await loadBotCommands();
await loadBotSecrets(); await loadBotSecrets();
await loadOverlays(); await loadOverlays();
@@ -311,6 +313,22 @@
} }
} }
async function loadCollaborators() {
try {
const response = await fetch(`${serverAddress}/api/v1/twitch/collaboration/collaborators`, { headers: { authorization: `Bearer ${sessionToken}` } });
if (response.ok) collaborators = await response.json();
} catch {
collaborators = [];
}
}
async function toggleCollaboratorFavorite(collaborator: (typeof collaborators)[number]) {
const method = collaborator.favorite ? 'DELETE' : 'POST';
const url = collaborator.favorite ? `${serverAddress}/api/v1/twitch/collaboration/favorites?twitch_user_id=${encodeURIComponent(collaborator.twitch_user_id)}` : `${serverAddress}/api/v1/twitch/collaboration/favorites`;
const response = await fetch(url, { method, headers: { authorization: `Bearer ${sessionToken}`, ...(method === 'POST' ? { 'content-type': 'application/json' } : {}) }, ...(method === 'POST' ? { body: JSON.stringify({ twitch_user_id: collaborator.twitch_user_id, display_name: collaborator.display_name }) } : {}) });
if (response.ok) await loadCollaborators();
}
async function createCollaboration() { async function createCollaboration() {
collaborationBusy = true; collaborationBusy = true;
collaborationError = ''; collaborationError = '';