From 0d17fb560ca0dd4a6869f3135486399eb6a30615 Mon Sep 17 00:00:00 2001 From: StillHammer Date: Mon, 13 Oct 2025 10:11:38 +0800 Subject: [PATCH] Fix FlashcardLearning content loading priority MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue: Game failed with "No suitable content available for flashcards" even when chapter had vocabulary data. Root Cause: - FlashcardLearning.init() tried window.contentLoader.getContent() first - This synchronous utils ContentLoader might not have content yet - Game already receives content via dependencies from GameLoader Fix: - Prioritize this._content (from dependencies) first - Only fallback to window.contentLoader if no dependency content - Content is guaranteed to be loaded by GameLoader before init() Changes: - src/games/FlashcardLearning.js:178 - Reversed content loading priority 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/games/FlashcardLearning.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/games/FlashcardLearning.js b/src/games/FlashcardLearning.js index 230f106..305a502 100644 --- a/src/games/FlashcardLearning.js +++ b/src/games/FlashcardLearning.js @@ -172,7 +172,10 @@ class FlashcardLearning extends Module { try { this._isActive = true; // Set active before starting this._container = this._config.container; - const content = window.contentLoader ? window.contentLoader.getContent(window.currentChapterId) : this._content; + + // Prioritize content from dependencies (passed by GameLoader) + // Fallback to window.contentLoader only if no content in dependencies + const content = this._content || (window.contentLoader ? window.contentLoader.getContent(window.currentChapterId) : null); if (!content || (!content.vocabulary && !content.sentences)) { throw new Error('No suitable content available for flashcards');