fix: playground back button goes to previous lesson
The Back button in playground now works the same as Previous button on other pages - it navigates to the previous lesson. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
This commit is contained in:
@@ -793,14 +793,6 @@ function nextLesson() {
|
|||||||
|
|
||||||
function prevLesson() {
|
function prevLesson() {
|
||||||
const engineState = lessonEngine.getCurrentState();
|
const engineState = lessonEngine.getCurrentState();
|
||||||
const isPlayground = engineState.lesson?.mode === "playground";
|
|
||||||
|
|
||||||
// In playground mode, "Back" navigates to home
|
|
||||||
if (isPlayground) {
|
|
||||||
navigateTo("#");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const prevModuleId = engineState.module?.id;
|
const prevModuleId = engineState.module?.id;
|
||||||
const success = lessonEngine.previousLesson();
|
const success = lessonEngine.previousLesson();
|
||||||
if (success) {
|
if (success) {
|
||||||
|
|||||||
21
src/auth.js
21
src/auth.js
@@ -52,8 +52,15 @@ export async function handleOAuthCallback() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear the hash after processing
|
// Restore the original route (saved before OAuth redirect)
|
||||||
|
const savedRoute = localStorage.getItem("codeCrispies.oauthReturnRoute");
|
||||||
|
if (savedRoute) {
|
||||||
|
localStorage.removeItem("codeCrispies.oauthReturnRoute");
|
||||||
|
window.history.replaceState(null, "", window.location.pathname + savedRoute);
|
||||||
|
} else {
|
||||||
|
// No saved route - just clear the hash
|
||||||
window.history.replaceState(null, "", window.location.pathname);
|
window.history.replaceState(null, "", window.location.pathname);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -322,8 +329,13 @@ function setupAuthForms() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// OAuth buttons
|
// OAuth buttons - save current route before redirect
|
||||||
document.getElementById("google-login")?.addEventListener("click", async () => {
|
document.getElementById("google-login")?.addEventListener("click", async () => {
|
||||||
|
// Save current route to restore after OAuth
|
||||||
|
const currentHash = window.location.hash;
|
||||||
|
if (currentHash && !currentHash.includes("access_token")) {
|
||||||
|
localStorage.setItem("codeCrispies.oauthReturnRoute", currentHash);
|
||||||
|
}
|
||||||
const { error } = await authModule?.signInWithGoogle() ?? { error: null };
|
const { error } = await authModule?.signInWithGoogle() ?? { error: null };
|
||||||
if (error) {
|
if (error) {
|
||||||
showOAuthError(error.message);
|
showOAuthError(error.message);
|
||||||
@@ -331,6 +343,11 @@ function setupAuthForms() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
document.getElementById("github-login")?.addEventListener("click", async () => {
|
document.getElementById("github-login")?.addEventListener("click", async () => {
|
||||||
|
// Save current route to restore after OAuth
|
||||||
|
const currentHash = window.location.hash;
|
||||||
|
if (currentHash && !currentHash.includes("access_token")) {
|
||||||
|
localStorage.setItem("codeCrispies.oauthReturnRoute", currentHash);
|
||||||
|
}
|
||||||
const { error } = await authModule?.signInWithGitHub() ?? { error: null };
|
const { error } = await authModule?.signInWithGitHub() ?? { error: null };
|
||||||
if (error) {
|
if (error) {
|
||||||
showOAuthError(error.message);
|
showOAuthError(error.message);
|
||||||
|
|||||||
Reference in New Issue
Block a user