import { db } from '../../db/database.js'; import { aiRouter } from '../../ai/router.js'; export class LearnView { constructor(containerId) { this.container = document.getElementById(containerId); this.decks = []; this.activeDeckId = null; this.dueCards = []; this.currentCardIndex = 0; } async init() { this.loadDecks(); window.addEventListener('flashcards-updated', () => { this.loadDecks(); // Don't interrupt if user is actively studying const isStudyMode = this.container.querySelector('.study-mode-container') !== null; if (isStudyMode) return; if (this.activeDeckId) { this.renderDeckDetails(this.activeDeckId); } else if (this.container.innerHTML.trim() !== '') { this.renderOverview(); } }); window.addEventListener('cloud_sync_updated', () => { this.loadDecks(); const isStudyMode = this.container.querySelector('.study-mode-container') !== null; if (isStudyMode) return; // Don't interrupt study if (this.activeDeckId) { this.renderDeckDetails(this.activeDeckId); } else if (this.container.innerHTML.trim() !== '') { this.renderOverview(); } }); } loadDecks() { this.decks = db.getDecks(); } render() { this.renderOverview(); } appAlert(message) { return new Promise(resolve => { const overlay = document.createElement('div'); overlay.className = 'custom-modal-overlay'; overlay.innerHTML = `
${message}
Du hast noch keine Karteikarten.
${deck.total_count} Karten insgesamt
Du hast alle anstehenden Karten gelernt.