"use client"; import { usePathname } from "next/navigation"; import { useEffect, useState } from "react"; import PlayLink from "@/components/projects/PlayLink"; import Link from "next/link"; import { projectHref } from "@/lib/hrefs"; // --------------------------------------------------------------------------- // RECENT CUTS, ON HOME (lane/ui-simplify, 5 Nov; the rail's until the // redesign's L4 left the rail navigation only): the last report videos this // viewer opened, each with ▶ Play (the newest take) -- so Play is one click from // home. A per-viewer convenience, so localStorage (wrapped: a private // window or blocked storage just shows nothing); on a project's // page and on Play writes it. // --------------------------------------------------------------------------- const KEY = "umtool.recentCuts"; const MAX = 4; type Recent = { project: string; title: string }; function read(): Recent[] { try { const v = JSON.parse(window.localStorage.getItem(KEY) ?? "[]"); return Array.isArray(v) ? v.filter((x) => x && typeof x.project === "string").slice(0, MAX) : []; } catch { return []; } } /** Remember a report video as just opened (no UI). */ export function RememberCut({ project, title }: { project: string; title: string }) { useEffect(() => { try { const next = [{ project, title }, ...read().filter((r) => r.project !== project)].slice(0, MAX); window.localStorage.setItem(KEY, JSON.stringify(next)); window.dispatchEvent(new Event("umtool:recent-cuts")); } catch { // storage refused: nothing to remember } }, [project, title]); return null; } export default function RecentCuts() { const [all, setList] = useState([]); // Not the one on screen (its own page has its Play), and named by its id's last part (the page names its title). const here = usePathname() ?? ""; const list = all.filter((r) => !here.startsWith(projectHref(r.project))); useEffect(() => { const on = () => setList(read()); on(); window.addEventListener("umtool:recent-cuts", on); window.addEventListener("storage", on); return () => { window.removeEventListener("umtool:recent-cuts", on); window.removeEventListener("storage", on); }; }, []); if (!list.length) return null; return (

Recent cuts

    {list.map((r) => (
  • {r.project.split("/").pop()}
  • ))}
); }