feat: implement Session Mode UI for Fund Once, Ask Many interactions
- Fix slideStyles used-before-declaration error in onboarding.tsx that blocked typecheck (introduced by #79). Moved slideStyles const above the slides array that references it. - Add missing DELETE /sessions/:id/history endpoint to sessions.ts. The frontend session.js calls this endpoint for the "Clear history" button but no matching route existed. Fixes #67
This commit is contained in:
@@ -569,4 +569,32 @@ router.post("/sessions/:id/topup", async (req: Request, res: Response) => {
|
||||
}
|
||||
});
|
||||
|
||||
// ── DELETE /sessions/:id/history ─────────────────────────────────────────────
|
||||
|
||||
router.delete("/sessions/:id/history", async (req: Request, res: Response) => {
|
||||
const id = req.params.id as string;
|
||||
const macaroon = extractMacaroon(req);
|
||||
|
||||
try {
|
||||
const session = await getSessionById(id);
|
||||
if (!session) { res.status(404).json({ error: "Session not found" }); return; }
|
||||
|
||||
if (!macaroon || macaroon !== session.macaroon) {
|
||||
res.status(401).json({ error: "Invalid or missing macaroon" });
|
||||
return;
|
||||
}
|
||||
|
||||
if (session.state !== "active" && session.state !== "paused") {
|
||||
res.status(409).json({ error: `Cannot clear history for a session in state '${session.state}'` });
|
||||
return;
|
||||
}
|
||||
|
||||
await db.delete(sessionMessages).where(eq(sessionMessages.sessionId, id));
|
||||
|
||||
res.json({ ok: true, sessionId: id });
|
||||
} catch (err) {
|
||||
res.status(500).json({ error: err instanceof Error ? err.message : "Failed to clear history" });
|
||||
}
|
||||
});
|
||||
|
||||
export default router;
|
||||
|
||||
@@ -21,6 +21,19 @@ import { ONBOARDING_COMPLETED_KEY } from "@/constants/storage-keys";
|
||||
const C = Colors.dark;
|
||||
const { width: SCREEN_WIDTH } = Dimensions.get("window");
|
||||
|
||||
const slideStyles = StyleSheet.create({
|
||||
iconCircle: {
|
||||
width: 140,
|
||||
height: 140,
|
||||
borderRadius: 70,
|
||||
backgroundColor: C.surfaceElevated,
|
||||
borderWidth: 1,
|
||||
borderColor: C.border,
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
},
|
||||
});
|
||||
|
||||
type Slide = {
|
||||
id: string;
|
||||
icon: React.ReactNode;
|
||||
@@ -158,19 +171,6 @@ export default function OnboardingScreen() {
|
||||
);
|
||||
}
|
||||
|
||||
const slideStyles = StyleSheet.create({
|
||||
iconCircle: {
|
||||
width: 140,
|
||||
height: 140,
|
||||
borderRadius: 70,
|
||||
backgroundColor: C.surfaceElevated,
|
||||
borderWidth: 1,
|
||||
borderColor: C.border,
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
},
|
||||
});
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
flex: 1,
|
||||
|
||||
Reference in New Issue
Block a user