1. Bugs fixed:
- Backup schema now accepts theme: "aero" so backups exported under
Frutiger Aero pass parseBackup on import, and applyImport in "replace"
mode replaces SRS schedules, answer history, and chats instead of
merging into existing SRS or skipping empty arrays.
- Typed FillBlank cards bind the input value to chosen ?? value instead
of chosen ?? "", and normalise() preserves Unicode letters (\p{L}\p{N})
when grading non-ASCII answers.
- OpenAI-compatible vision calls (contentFor in lib/openai-compat.ts)
prefix data:image/jpeg;base64, when routes pass stripped base64.
- Streaming calls (ollamaChatStream, providerChatStream) keep their
AbortController active across the entire body stream and API routes
forward request.signal so stopping a chat or cancelling a run aborts
the upstream request immediately.
- HomeworkCard uses homeworkModeLabelKey so "check" records display the
Checked label instead of Step-by-step guide.
- Desktop dropzones on /create and /homework accept dropped documents as
well as images.
- LibraryScreen filters reported questions out of its due and mistake
counts to match ReviewClient.
- Clearing a provider key resets generation if it pointed at that
provider; chat conversations persist and restore provider; ModelPicker
keys items by provider:name.
- RouteTransition no longer mutates module-level lastPath during render.
- Service worker asset handler falls back to Response.error() when an
uncached asset fetch fails offline.
- Confetti and .ice-orb / .ice-bubble respect the in-app reduce-motion
toggle.
2. Performance & cleanup:
- Deduplicate window storage listeners across all six localStorage
stores (one listener while subscribed instead of N^2 notifications).
- Use todayAnswerCount in LibraryScreen and pass sorted folders to
DeckCard.
- Memoize MessageRow with stable callbacks in ChatScreen and compute
last message IDs in a single pass.
- Close ImageBitmap after drawing in lib/image.ts and destroy pdf.js
documents in finally in lib/documents.ts.
- Avoid re-parsing serialized sync payloads in POST /api/sync.
- Deduplicate copyText (lib/share.ts -> lib/clipboard.ts), chatMessageId,
describeExtraction, ALL_FOLDERS, useIsPhone, and remove unused helpers
and boilerplate public/*.svg files.
Version 0.5.8, SW -> freezmo-v80.
54 lines
1.8 KiB
TypeScript
54 lines
1.8 KiB
TypeScript
"use client";
|
|
|
|
import { motion } from "framer-motion";
|
|
import { useAppReducedMotion as useReducedMotion } from "@/lib/motion-pref";
|
|
import { usePathname } from "next/navigation";
|
|
import { useEffect, useState } from "react";
|
|
|
|
import { screenVariants, tabVariants } from "@/lib/motion";
|
|
|
|
/**
|
|
* Direction-aware screen entrance for the page content column.
|
|
*
|
|
* Deeper paths (library → deck, library → create/homework) slide in from the
|
|
* right; going back slides from the left; same-depth switches crossfade.
|
|
* The wrapper only ever wraps the scrolling content column — fixed chrome
|
|
* (tab bar, sheets) stays outside it, so a transform can never capture it.
|
|
*
|
|
* Note: the App Router unmounts the outgoing page immediately, so this is an
|
|
* entrance animation (exits animate for in-page elements via AnimatePresence,
|
|
* e.g. list items).
|
|
*/
|
|
|
|
/** Module-level so the direction survives the per-route remount. */
|
|
let lastPath: string | null = null;
|
|
|
|
function depth(path: string): number {
|
|
if (path === "/") return 0;
|
|
return path.split("/").filter(Boolean).length;
|
|
}
|
|
|
|
export function RouteTransition({ children }: { children: React.ReactNode }) {
|
|
const pathname = usePathname();
|
|
const reduceMotion = useReducedMotion();
|
|
|
|
const [{ isTabSwitch, direction }] = useState(() => {
|
|
const previous = typeof window === "undefined" ? null : lastPath;
|
|
return {
|
|
isTabSwitch: previous !== null && depth(previous) === depth(pathname) && previous !== pathname,
|
|
direction: (previous === null || depth(pathname) >= depth(previous) ? 1 : -1) as 1 | -1,
|
|
};
|
|
});
|
|
|
|
useEffect(() => {
|
|
lastPath = pathname;
|
|
}, [pathname]);
|
|
|
|
const variants = isTabSwitch ? tabVariants(!!reduceMotion) : screenVariants(direction, !!reduceMotion);
|
|
|
|
return (
|
|
<motion.div initial="initial" animate="animate" variants={variants}>
|
|
{children}
|
|
</motion.div>
|
|
);
|
|
}
|