Add kick player and leave game functionality

- Host can kick players from lobby (removes from game, clears presenter if needed)
- Client can voluntarily leave game
- Fix browser-compatible base64 decoding for document upload (atob vs Buffer)
This commit is contained in:
Joey Yakimowich-Payne 2026-01-19 14:52:57 -07:00
commit 79820f5298
No known key found for this signature in database
GPG key ID: DDF6AF5B21B407D4
7 changed files with 1640 additions and 10 deletions

View file

@ -130,11 +130,20 @@ function transformToQuiz(data: any): Quiz {
}
async function uploadNativeDocument(ai: GoogleGenAI, doc: ProcessedDocument): Promise<{ uri: string; mimeType: string }> {
const buffer = typeof doc.content === 'string'
? Buffer.from(doc.content, 'base64')
: doc.content;
let data: ArrayBuffer;
const blob = new Blob([buffer], { type: doc.mimeType });
if (typeof doc.content === 'string') {
const binaryString = atob(doc.content);
const bytes = new Uint8Array(binaryString.length);
for (let i = 0; i < binaryString.length; i++) {
bytes[i] = binaryString.charCodeAt(i);
}
data = bytes.buffer as ArrayBuffer;
} else {
data = doc.content;
}
const blob = new Blob([data], { type: doc.mimeType });
const uploadedFile = await ai.files.upload({
file: blob,