feat(03-05): wire parent area into app.ts
- Import showParentCodePrompt and initParentScreen from ui/parent - Register global Ctrl+Shift+E keyboard listener in initApp - Initialize parent screen with back-to-forest callback
This commit is contained in:
+16
@@ -4,6 +4,7 @@ import { initWelcomeScreen, initLessonScreen } from "./ui/screens";
|
||||
import { initForestScreen } from "./forest/scene";
|
||||
import { getGreeting } from "./companion/companion";
|
||||
import { companions } from "./companion/characters";
|
||||
import { showParentCodePrompt, initParentScreen } from "./ui/parent";
|
||||
|
||||
let db: IDBDatabase;
|
||||
let lessonCleanup: (() => void) | null = null;
|
||||
@@ -86,6 +87,21 @@ function startLessonFromForest(level: number): void {
|
||||
|
||||
export async function initApp(): Promise<void> {
|
||||
db = await openDB();
|
||||
|
||||
// Wire parent screen back button
|
||||
initParentScreen(db, async () => {
|
||||
await initForestScreen(db, startLessonFromForest);
|
||||
showScreen("forest");
|
||||
});
|
||||
|
||||
// Global keyboard shortcut for parent area (Ctrl+Shift+E)
|
||||
document.addEventListener("keydown", (e) => {
|
||||
if (e.ctrlKey && e.shiftKey && e.key === "E") {
|
||||
e.preventDefault();
|
||||
showParentCodePrompt();
|
||||
}
|
||||
});
|
||||
|
||||
const progress = await getProgress(db);
|
||||
if (progress && progress.selectedCharacter) {
|
||||
// Returning user -- init forest and go there
|
||||
|
||||
Reference in New Issue
Block a user