e621 polish: cached results, search context, DText descriptions

- e621 list/post queries use a 5 minute staleTime and 30 minute gcTime,
  so opening a post and coming back shows the same results with no
  refetch; global gcTime raised to 30 minutes
- post card links carry their originating search in route state; the
  detail back link returns to it and related-post links keep it
- new navigations scroll to top while history back/forward keeps the
  previous position
- DText renderer for e621 descriptions (b/i/u/s, sup/sub, code, spoiler,
  quote, color, url/wiki/thumb, headings, lists, sections, expand
  blocks, named and bare links) built as React elements, no raw HTML
- Spoiler moved to its own component; trailing punctuation no longer
  swallowed into links
This commit is contained in:
2026-09-17 09:19:25 -05:00
parent 04448bf615
commit 81939d8ca3
7 changed files with 562 additions and 8 deletions
+8 -1
View File
@@ -1,7 +1,7 @@
import { useQuery } from "@tanstack/react-query";
import { LogOut, Menu } from "lucide-react";
import { useEffect, useState } from "react";
import { Link, NavLink, Outlet, useLocation } from "react-router-dom";
import { Link, NavLink, Outlet, useLocation, useNavigationType } from "react-router-dom";
import { CommandPalette } from "@/components/CommandPalette";
import { StatusFooter } from "@/components/StatusFooter";
@@ -63,6 +63,13 @@ export function AppShell() {
const showSidebarToggle =
location.pathname === "/" || location.pathname === "/online";
const navigationType = useNavigationType();
useEffect(() => {
// New navigations start at the top; history back/forward keeps position.
if (navigationType === "POP") return;
window.scrollTo({ top: 0 });
}, [location.pathname, navigationType]);
return (
<div className="flex min-h-screen flex-col">
<header className="sticky top-0 z-40 border-b border-ctp-surface0 bg-ctp-crust/95 backdrop-blur">
+20
View File
@@ -0,0 +1,20 @@
import { useState, type ReactNode } from "react";
export function Spoiler({ children }: { children: ReactNode }) {
const [revealed, setRevealed] = useState(false);
if (revealed) return <span>{children}</span>;
return (
<span
role="button"
tabIndex={0}
title="Click to reveal spoiler"
onClick={() => setRevealed(true)}
onKeyDown={(event) => {
if (event.key === "Enter" || event.key === " ") setRevealed(true);
}}
className="cursor-pointer rounded bg-ctp-surface1 px-1 text-transparent transition hover:bg-ctp-surface2"
>
{children}
</span>
);
}