diff --git a/server/src/accessGroups.js b/server/src/accessGroups.js index ad8c025..5c636c7 100644 --- a/server/src/accessGroups.js +++ b/server/src/accessGroups.js @@ -66,24 +66,16 @@ export async function groupRole(db, email) { /* Brings a group account in line with `role` (null: in no group). Returns what changed, as text for the log and the Panel, or null. */ export function applyGroupRole(db, user, role) { - // `user` was read before the group lookups were awaited, so each - // write rechecks that a superadmin hasn't disabled or promoted the - // account meanwhile. - const STILL_OURS = `AND role <> 'superadmin' AND (is_active = 1 OR group_disabled = 1)`; let change = null; if (!role) { if (user.is_active === 1) { - const res = db - .prepare(`UPDATE admin_users SET is_active = 0, group_disabled = 1 WHERE id = ? ${STILL_OURS}`) - .run(user.id); + db.prepare(`UPDATE admin_users SET is_active = 0, group_disabled = 1 WHERE id = ?`).run(user.id); db.prepare(`DELETE FROM sessions WHERE user_id = ?`).run(user.id); - if (res.changes) change = "disabled: in no access group"; + change = "disabled: in no access group"; } } else if (user.is_active !== 1 || user.role !== role) { - const res = db - .prepare(`UPDATE admin_users SET role = ?, is_active = 1, group_disabled = 0 WHERE id = ? ${STILL_OURS}`) - .run(role, user.id); - if (res.changes) change = user.is_active !== 1 ? `enabled as ${role}` : `${user.role} → ${role}`; + db.prepare(`UPDATE admin_users SET role = ?, is_active = 1, group_disabled = 0 WHERE id = ?`).run(role, user.id); + change = user.is_active !== 1 ? `enabled as ${role}` : `${user.role} → ${role}`; } db.prepare(`UPDATE admin_users SET groups_checked_at = datetime('now') WHERE id = ?`).run(user.id); if (change) console.log(`access: ${user.email} ${change}`); diff --git a/server/src/admin-crud.js b/server/src/admin-crud.js index baaa667..d7afa70 100644 --- a/server/src/admin-crud.js +++ b/server/src/admin-crud.js @@ -163,23 +163,18 @@ export function listRows(db, entity, query = {}) { } const limit = Math.max(1, Math.min(Number(query.limit) || 200, 500)); - const offset = Math.max(0, Math.floor(Number(query.offset) || 0)); - const whereSql = where.length ? `WHERE ${where.join(" AND ")}` : ""; const rows = db .prepare( `SELECT ${columns.join(", ")} FROM ${entity.table} - ${whereSql} + ${where.length ? `WHERE ${where.join(" AND ")}` : ""} ORDER BY ${order} - LIMIT ? OFFSET ?`, + LIMIT ?`, ) - .all(...params, limit, offset); + .all(...params, limit); - // Every match, not just this page, so the list can say how many more. - const { total } = db.prepare(`SELECT COUNT(*) AS total FROM ${entity.table} ${whereSql}`).get(...params); - - return { rows, total }; + return { rows, total: rows.length }; } export function readRow(db, entity, rawId) { diff --git a/server/src/docx.js b/server/src/docx.js index 09d0567..2c70e46 100644 --- a/server/src/docx.js +++ b/server/src/docx.js @@ -63,8 +63,7 @@ function unzip(buf, wanted) { const local = buf.readUInt32LE(at + 42); const name = buf.toString("utf8", at + 46, at + 46 + nameLen); at += 46 + nameLen + extraLen + commentLen; - // Each part once: a zip can list the same name thousands of times. - if (!wanted.includes(name) || name in out) continue; + if (!wanted.includes(name)) continue; if (size > MAX_PART_BYTES) throw new DocxError("That document is too large to import."); const dataAt = local + 30 + buf.readUInt16LE(local + 26) + buf.readUInt16LE(local + 28); const data = buf.subarray(dataAt, dataAt + packed); diff --git a/server/src/googleService.js b/server/src/googleService.js index 78d03c1..3aca412 100644 --- a/server/src/googleService.js +++ b/server/src/googleService.js @@ -35,7 +35,7 @@ import { createReadStream, readFileSync } from "node:fs"; import { stat } from "node:fs/promises"; import { Readable } from "node:stream"; -import { createSign, randomBytes } from "node:crypto"; +import { createSign } from "node:crypto"; const DRIVE_SCOPE = "https://www.googleapis.com/auth/drive"; const GMAIL_SCOPE = "https://www.googleapis.com/auth/gmail.send"; @@ -183,8 +183,7 @@ async function findOrMakeFolder(path) { /* One file into a folder of the shared drive (driveFolder). Returns { id, webViewLink }: Drive's id, and the page that shows it. */ export async function driveUpload(folder, name, mime, buffer) { - // Random, so no file can carry it by chance or design. - const boundary = `ngu${randomBytes(16).toString("hex")}`; + const boundary = `ngu${Date.now().toString(36)}`; const meta = JSON.stringify({ name, parents: [await driveFolder(folder)] }); const body = Buffer.concat([ Buffer.from( diff --git a/server/src/index.js b/server/src/index.js index 7cd715b..104101c 100644 --- a/server/src/index.js +++ b/server/src/index.js @@ -13,7 +13,6 @@ import { mkdir } from "node:fs/promises"; import { serve } from "@hono/node-server"; import { serveStatic } from "@hono/node-server/serve-static"; import { Hono } from "hono"; -import { bodyLimit } from "hono/body-limit"; import { HTTPException } from "hono/http-exception"; import { csrf } from "hono/csrf"; import { logger } from "hono/logger"; @@ -119,12 +118,6 @@ app.use( }), ); -/* The public JSON writes read their whole body before trimming it, - so each is capped well above its longest real body (a 5000 - character message) and far below nginx's limit. */ -const smallBody = bodyLimit({ maxSize: 64 * 1024, onError: (c) => c.json({ error: "That's too long." }, 413) }); -for (const path of ["/api/csp-report", "/api/feedback", "/api/auth/login"]) app.use(path, smallBody); - /* What the policy above would have blocked. Browsers post these on their own; a short line per report is plenty to go on. */ app.use("/api/csp-report", rateLimit({ windowMs: 60_000, max: 30 })); diff --git a/server/src/migrations/059_events_view.sql b/server/src/migrations/059_events_view.sql deleted file mode 100644 index 64963e0..0000000 --- a/server/src/migrations/059_events_view.sql +++ /dev/null @@ -1,50 +0,0 @@ --- ═══════════════════════════════════════════════════════════════ --- 059 EVENTS VIEW: FIRST PUBLISHED HOST, READ DIRECTLY --- --- v_events took its host (name, logo, color) from the first row of --- v_event_hosts, published or not, so a draft partner hosting a --- published event showed in its page's structured data and preview --- image. It now takes the first published host, as loadHosts does. --- --- It also joins event_hosts, organizations and people itself: --- through the v_event_hosts view, SQLite built every host of every --- event for each lookup, even one event's page. Same columns. --- --- person_awards gets the index its event_id lookups (an event's --- awards, and the SET NULL when an event is deleted) were missing. --- ═══════════════════════════════════════════════════════════════ - -DROP VIEW v_events; - -CREATE VIEW v_events AS -SELECT - e.*, - CASE WHEN eh.id IS NULL THEN NULL - WHEN eh.person_id IS NULL THEN 'organization' ELSE 'person' END - AS host_kind, - COALESCE(eh.org_id, eh.person_id) AS host_id, - COALESCE(o.name, p.display_name) AS host_name, - o.kind AS host_org_kind, - COALESCE(e.org_logo, o.logo) AS effective_org_logo, - COALESCE(e.color, o.color) AS effective_color, - COALESCE( - e.status, - CASE WHEN e.ends_on IS NOT NULL AND e.ends_on < date('now') - THEN 'past' ELSE 'upcoming' END - ) AS effective_status -FROM events e -LEFT JOIN event_hosts eh - ON eh.id = ( - SELECT x.id - FROM event_hosts x - LEFT JOIN organizations xo ON xo.id = x.org_id - LEFT JOIN people xp ON xp.id = x.person_id - WHERE x.event_id = e.id - AND COALESCE(xo.is_published, xp.is_published) = 1 - ORDER BY x.sort_order, x.id - LIMIT 1 - ) -LEFT JOIN organizations o ON o.id = eh.org_id -LEFT JOIN people p ON p.id = eh.person_id; - -CREATE INDEX person_awards_event_idx ON person_awards (event_id); diff --git a/server/src/routes/auth.js b/server/src/routes/auth.js index 157c0f6..e3b1ad9 100644 --- a/server/src/routes/auth.js +++ b/server/src/routes/auth.js @@ -262,11 +262,8 @@ auth.get("/google/callback", async (c) => { } // A group account's role follows its groups, checked every time. - // One a superadmin disabled stays disabled whatever its groups say, - // and with access groups switched off none gets in (it can't be - // rechecked, so it would keep its last role for good). - if (user.access_source === "group" && user.role !== "superadmin") { - if (!accessEnabled(db)) return backToLogin(c, "not_in_group"); + // One a superadmin disabled stays disabled whatever its groups say. + if (user.access_source === "group" && user.role !== "superadmin" && accessEnabled(db)) { if (user.is_active !== 1 && user.group_disabled !== 1) return backToLogin(c, "disabled"); const found = await roleFromGroups(); if (found.failed) return backToLogin(c, "groups_unreachable"); diff --git a/server/src/routes/content.js b/server/src/routes/content.js index 6d65d0e..820086a 100644 --- a/server/src/routes/content.js +++ b/server/src/routes/content.js @@ -442,8 +442,8 @@ function attachAwards(db, orgs) { } /* ── Events ──────────────────────────────────────────────────── - Flat, with the event scopes alongside, narrowed by the query - (below). Each band asks for only what it shows. + Flat, with the event scopes alongside. Retreats.tsx owns the + band titles and colors and filters this list by scope_id. Oldest first, undated last. The carousel shows the list as it comes and opens on the first upcoming event, so past events @@ -461,26 +461,13 @@ content.get("/events", (c) => { .prepare(`SELECT id, name, sort_order FROM event_scopes ORDER BY sort_order`) .all(); - // Optional filters, each narrowing the list (src/lib/eventData.ts): - // ?scope=national ?host= ?status=upcoming - // ?type=class,workshop - const where = [`is_published = 1`, `is_listed = 1`]; - const params = []; - const scope = c.req.query("scope"); - if (scope) where.push(`scope_id = ?`), params.push(scope); - const host = c.req.query("host"); - if (host) { - where.push(`EXISTS (SELECT 1 FROM event_hosts h WHERE h.event_id = v_events.id AND (h.org_id = ? OR h.person_id = ?))`); - params.push(host, host); - } - const status = c.req.query("status"); - if (status) where.push(`effective_status = ?`), params.push(status); - const types = (c.req.query("type") ?? "").split(",").filter(Boolean).slice(0, 20); - if (types.length) where.push(`event_type IN (${marks(types.length)})`), params.push(...types); - const rows = db - .prepare(`SELECT * FROM v_events WHERE ${where.join(" AND ")} ORDER BY ${EVENT_ORDER}`) - .all(...params); + .prepare( + `SELECT * FROM v_events + WHERE is_published = 1 AND is_listed = 1 + ORDER BY ${EVENT_ORDER}`, + ) + .all(); const ids = rows.map((row) => row.id); const links = loadLinks(db, "event", ids); @@ -589,17 +576,20 @@ content.get("/organizations", (c) => { const ids = rows.map((row) => row.id); const links = loadLinks(db, "organization", ids); const cards = loadBlocks(db, "organization", ids, "card"); + const bodies = loadBlocks(db, "organization", ids, "body"); - // No body blocks or leadership: they grow with every organization - // and only a group's own detail panel or page shows them, which - // fetch /organizations/:id. - const organizations = rows.map((row) => { - const { blocks, leadership, ...org } = shapeOrganization(row, links.get(row.id) ?? [], cards.get(row.id) ?? [], []); - return org; - }); + const organizations = rows.map((row) => + shapeOrganization( + row, + links.get(row.id) ?? [], + cards.get(row.id) ?? [], + bodies.get(row.id) ?? [], + ), + ); attachRegionDetails(db, organizations); attachGroupDetails(db, organizations); + attachLeadership(db, organizations); return json(c, { organizations }); }); diff --git a/server/src/routes/files.js b/server/src/routes/files.js index 702b465..0b15465 100644 --- a/server/src/routes/files.js +++ b/server/src/routes/files.js @@ -86,15 +86,9 @@ export const inDrive = (folder) => (folder ? `${FOLDER}/${folder}` : FOLDER); Returns what the list shows. Also how the clip tool's Save to Drive lands (routes/clips.js). */ export async function recordDriveUpload(db, uploaded, { name, mime, bytes, folder, userId }) { - // A pick-up may have found it in Drive before this insert: ours wins. - const { id } = db - .prepare( - `INSERT INTO drive_files (drive_id, name, mime, bytes, url, folder, uploaded_by) VALUES (?, ?, ?, ?, ?, ?, ?) - ON CONFLICT (drive_id) DO UPDATE SET name = excluded.name, mime = excluded.mime, bytes = excluded.bytes, - url = excluded.url, folder = excluded.folder, uploaded_by = excluded.uploaded_by - RETURNING id`, - ) - .get(uploaded.id, name, mime, bytes, uploaded.webViewLink, folder, userId); + const id = db + .prepare(`INSERT INTO drive_files (drive_id, name, mime, bytes, url, folder, uploaded_by) VALUES (?, ?, ?, ?, ?, ?, ?)`) + .run(uploaded.id, name, mime, bytes, uploaded.webViewLink, folder, userId).lastInsertRowid; await fetchPreview(db, db.prepare(`${SELECT} WHERE f.id = ?`).get(id), userId); return shape(db.prepare(`${SELECT} WHERE f.id = ?`).get(id)); } @@ -207,13 +201,9 @@ async function pickUp(db, force = false) { continue; } refused.delete(file.id); - // OR IGNORE: another pick-up, or an upload between Drive and its - // own insert, may have recorded it meanwhile. - const res = db - .prepare(`INSERT OR IGNORE INTO drive_files (drive_id, name, mime, bytes, url, folder) VALUES (?, ?, ?, ?, ?, ?)`) - .run(file.id, safeName(file.name), file.mimeType, Number(file.size ?? 0), file.webViewLink, file.folder); - if (!res.changes) continue; - const id = res.lastInsertRowid; + const id = db + .prepare(`INSERT INTO drive_files (drive_id, name, mime, bytes, url, folder) VALUES (?, ?, ?, ?, ?, ?)`) + .run(file.id, safeName(file.name), file.mimeType, Number(file.size ?? 0), file.webViewLink, file.folder).lastInsertRowid; console.log(`files: ${file.name} picked up from Drive`); // In the background: a folder of new files shouldn't hold the list. fetchPreview(db, db.prepare(`SELECT * FROM drive_files WHERE id = ?`).get(id), null); diff --git a/server/src/routes/people.js b/server/src/routes/people.js index dd6bef9..38cb92f 100644 --- a/server/src/routes/people.js +++ b/server/src/routes/people.js @@ -26,9 +26,8 @@ import { postsBy } from "./blog.js"; const people = new Hono(); -/* How many slugs one request may name. Keeps the URL sane (a few - KB) while covering any hand-picked list. */ -const MAX_IDS = 200; +/* How many slugs one request may name. Keeps the URL sane. */ +const MAX_IDS = 50; function shapePerson(row) { return { @@ -70,10 +69,9 @@ people.get("/teams/:id/people", (c) => { const team = db .prepare( - `SELECT t.id, t.org_id, t.name, t.tagline, t.color, t.logo - FROM teams t - JOIN organizations o ON o.id = t.org_id AND o.is_published = 1 - WHERE t.id = ? AND t.is_published = 1`, + `SELECT id, org_id, name, tagline, color, logo + FROM teams + WHERE id = ? AND is_published = 1`, ) .get(id); @@ -127,7 +125,7 @@ people.get("/people", (c) => { o.id AS primary_org_id, o.name AS primary_org_name FROM people p - LEFT JOIN organizations o ON o.id = p.primary_org_id AND o.is_published = 1 + LEFT JOIN organizations o ON o.id = p.primary_org_id WHERE p.id IN (${marks(ids.length)}) AND p.is_published = 1`, ) diff --git a/server/src/routes/requests.js b/server/src/routes/requests.js index 81d0ca3..ea67685 100644 --- a/server/src/routes/requests.js +++ b/server/src/routes/requests.js @@ -79,17 +79,15 @@ export const TYPE_FOLDERS = { export const MAX_FILES = 3; export const MAX_FILE_BYTES = 10 * 1024 * 1024; -/* What a file is, from its first bytes, and only when its name says - the same: a PDF named .html is refused, so a download is always - what it says. */ +/* What a file is, from its first bytes. A zip is only taken as a + Word document when it's named like one. */ const DOCX = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; function kindOf(bytes, name) { - const ext = String(name).toLowerCase().match(/\.([a-z0-9]+)$/)?.[1]; const starts = (...sig) => sig.every((b, i) => bytes[i] === b); - if (ext === "pdf" && starts(0x25, 0x50, 0x44, 0x46, 0x2d)) return "application/pdf"; - if ((ext === "jpg" || ext === "jpeg") && starts(0xff, 0xd8, 0xff)) return "image/jpeg"; - if (ext === "png" && starts(0x89, 0x50, 0x4e, 0x47)) return "image/png"; - if (ext === "docx" && starts(0x50, 0x4b, 0x03, 0x04)) return DOCX; + if (starts(0x25, 0x50, 0x44, 0x46, 0x2d)) return "application/pdf"; + if (starts(0xff, 0xd8, 0xff)) return "image/jpeg"; + if (starts(0x89, 0x50, 0x4e, 0x47)) return "image/png"; + if (starts(0x50, 0x4b, 0x03, 0x04) && /\.docx$/i.test(name)) return DOCX; return null; } diff --git a/src/lib/eventData.ts b/src/lib/eventData.ts index 8d0b40d..a06751d 100644 --- a/src/lib/eventData.ts +++ b/src/lib/eventData.ts @@ -1,9 +1,10 @@ /* ═══════════════════════════════════════════════════════════════ EVENT DATA - Events, narrowed by the server. Each filter is part of the path, - so the cache in api.ts gives each its own entry and callers - asking the same thing share one fetch. + One request, filtered per band. The Retreats page has three + bands of events, and all three call this hook, the cache in + api.ts keys on the path, so they share a single fetch and each + narrows the result to what it shows. useEvents({ scope: "national" }) one band useEvents({ host: "northwest" }) one host's events @@ -23,33 +24,47 @@ No fallback. An empty list on a failed request would read as "nothing scheduled" when the truth is "the server is down", so the error comes back and each caller says so. + + Filtering here rather than in the query keeps the endpoint to + one cached response. At a few dozen events that's the right + trade; if the list ever runs to hundreds, move the filters into + the URL and let each become its own cache entry. ═══════════════════════════════════════════════════════════════ */ +import { useMemo } from "react"; + import { useResource } from "./useResource.ts"; -/* Shared empty lists, so a memo keyed on them doesn't +/* One shared empty list, so a memo keyed on `scopes` doesn't restart on every render before the data arrives. */ const NO_SCOPES: any[] = []; -const NO_EVENTS: any[] = []; -/* The path for a filter, as the server reads it (routes/content.js). */ -export function eventsPath({ scope, host, status, type }: any = {}) { - const query = new URLSearchParams(); - if (scope) query.set("scope", scope); - // An organization or a person slug: co-hosting puts one event on - // both hosts' lists, which is the point. - if (host) query.set("host", host); - if (status) query.set("status", status); - const types = Array.isArray(type) ? type.join(",") : type; - if (types) query.set("type", types); - const qs = query.toString(); - return qs ? `/events?${qs}` : "/events"; -} +export function useEvents({ scope, host, status, type }: any = {}) { + const { data, error, loading } = useResource("/events"); -export function useEvents(filter: any = {}) { - const { data, error, loading } = useResource(eventsPath(filter)); - const events = data?.events ?? NO_EVENTS; + const all = data?.events; const scopes = data?.scopes ?? NO_SCOPES; + + /* An array prop is a new identity on every render, which would + restart the memo each time. Joining it gives the dependency + list something stable to compare. */ + const typeKey = Array.isArray(type) ? type.join(",") : (type ?? ""); + + const events = useMemo(() => { + let list = all ?? []; + if (scope) list = list.filter(e => e.scope_id === scope); + // `host` is an organization or a person slug, and an event can + // have several of either, co-hosting puts one event on both + // hosts' lists, which is the point. + if (host) list = list.filter(e => e.hosts?.some(h => h.id === host)); + if (status) list = list.filter(e => e.status === status); + if (typeKey) { + const wanted = new Set(typeKey.split(",")); + list = list.filter(e => wanted.has(e.event_type)); + } + return list; + }, [all, scope, host, status, typeKey]); + return { events, scopes, loading, error }; } diff --git a/src/lib/useContent.ts b/src/lib/useContent.ts index 4707bec..79bc338 100644 --- a/src/lib/useContent.ts +++ b/src/lib/useContent.ts @@ -254,7 +254,7 @@ export type OrganizationRecord = { /** One row of GET /organizations: the card surface and details, * without the sections only the org's own page loads. */ -export type OrganizationListItem = Omit & { +export type OrganizationListItem = Omit & { sort_order: number } diff --git a/src/lib/version.ts b/src/lib/version.ts index c6facf3..c391647 100644 --- a/src/lib/version.ts +++ b/src/lib/version.ts @@ -7,4 +7,4 @@ box or a build banner can read the same value later. ═══════════════════════════════════════════════════════════════ */ -export const SITE_VERSION = "NGU-Web.v1.11.0-audit"; +export const SITE_VERSION = "NGU-Web.v1.10.10"; diff --git a/src/pages/Home.tsx b/src/pages/Home.tsx index 8c217ac..7058b29 100644 --- a/src/pages/Home.tsx +++ b/src/pages/Home.tsx @@ -77,12 +77,12 @@ const BANDS: Record ReactNode> = { export default function Home() { const { data: page, error, reload } = useFrontPage() - // The bands below ask for the timeline once the front page has said - // which of them to show. Start it now, alongside it: api.ts hands the - // same request to the band when it mounts, so the page waits for one - // round trip instead of two. Events aren't fetched ahead: each band - // asks the server for only its own, so there's no one list to start. + // The bands below ask for events and the timeline once the front + // page has said which of them to show. Start both now, alongside it: + // api.ts hands the same request to the bands when they mount, so + // the page waits for one round trip instead of two. useEffect(() => { + get('/events').catch(() => {}) get('/history').catch(() => {}) }, []) diff --git a/src/pages/admin/AdminFeedback.tsx b/src/pages/admin/AdminFeedback.tsx index b977fea..816837a 100644 --- a/src/pages/admin/AdminFeedback.tsx +++ b/src/pages/admin/AdminFeedback.tsx @@ -208,16 +208,7 @@ function RequestRecord({ row }) { setError(null); try { const params = new URLSearchParams({ limit: "500", ...(type.preset ?? {}) }); - // The records matching the request's name, however far down the - // list they sort, then the first 500 for picking by hand. - const search = new URLSearchParams(params); - search.set("q", String(row.subject ?? "").trim().slice(0, 100)); - const [matches, all] = await Promise.all([ - search.get("q") ? get(`/admin/${type.entity}?${search}`, { ttl: 0 }) : { rows: [] }, - get(`/admin/${type.entity}?${params}`, { ttl: 0 }), - ]); - const seen = new Set(); - const rows = [...matches.rows, ...all.rows].filter((r) => !seen.has(r.id) && seen.add(r.id)); + const { rows } = await get(`/admin/${type.entity}?${params}`, { ttl: 0 }); const wanted = String(row.subject ?? "").toLowerCase().trim(); const name = (r) => String(r[type.heading] ?? r.id); // The closest name first: exact, then containing, then the rest. diff --git a/src/pages/admin/AdminNewsletter.tsx b/src/pages/admin/AdminNewsletter.tsx index 4223445..bdd3505 100644 --- a/src/pages/admin/AdminNewsletter.tsx +++ b/src/pages/admin/AdminNewsletter.tsx @@ -109,8 +109,8 @@ export default function AdminNewsletter() { const cards = frontPage?.featured ?? [] useEffect(() => { - get('/admin/blog_posts?is_published=1&is_listed=1&limit=200', { ttl: 0 }) - .then((data: { rows: PostRow[] }) => setPosts(data.rows)) + get('/admin/blog_posts?limit=200', { ttl: 0 }) + .then((data: { rows: PostRow[] }) => setPosts(data.rows.filter((row) => row.is_published && row.is_listed))) .catch(() => setPosts([])) }, []) diff --git a/src/pages/admin/EntityList.tsx b/src/pages/admin/EntityList.tsx index 94b5bb6..0363997 100644 --- a/src/pages/admin/EntityList.tsx +++ b/src/pages/admin/EntityList.tsx @@ -28,8 +28,6 @@ export default function EntityList() { const [params, setParams] = useSearchParams(); const [rows, setRows] = useState([]); - const [total, setTotal] = useState(0); - const [loadingMore, setLoadingMore] = useState(false); const [options, setOptions] = useState({}); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); @@ -55,7 +53,6 @@ export default function EntityList() { get("/admin/options", { ttl: 60_000 }), ]); setRows(list.rows); - setTotal(list.total); setOptions(opts.options); } catch (err) { if (isUnauthorized(err)) return navigate("/admin/login", { replace: true }); @@ -69,22 +66,6 @@ export default function EntityList() { load(); }, [load]); - // The server sends a page at a time; the next one goes under it. - async function loadMore() { - setLoadingMore(true); - try { - const next = new URLSearchParams(params); - next.set("offset", String(rows.length)); - const list = await get(`/admin/${manifest.key}?${next}`, { ttl: 0 }); - setRows((current) => [...current, ...list.rows]); - setTotal(list.total); - } catch (err) { - setError(err instanceof ApiError ? err.message : "Couldn't reach the server."); - } finally { - setLoadingMore(false); - } - } - if (!manifest) { return

No such thing to edit.

; } @@ -230,22 +211,6 @@ export default function EntityList() { )} {loading &&

Loading…

} - - {!loading && rows.length < total && ( -
- -

- {rows.length} of {total} -

-
- )} ); } diff --git a/src/pages/sections/OrgList-Map.tsx b/src/pages/sections/OrgList-Map.tsx index a7e8f53..3dc3a51 100644 --- a/src/pages/sections/OrgList-Map.tsx +++ b/src/pages/sections/OrgList-Map.tsx @@ -1,7 +1,6 @@ import { CaretRight, X } from '@phosphor-icons/react'; import { useEffect, useRef, useState } from "react"; import { useCommunity } from "../../lib/useCommunity.ts"; -import { useOrganization } from "../../lib/useContent.ts"; import { Link } from "react-router-dom"; import ArrowLink from "../../components/ArrowLink.tsx"; import OrgLogo from "../../components/OrgLogo.tsx"; @@ -523,13 +522,9 @@ function GroupCard({ group, color, open, onOpen }) { } function GroupDetail({ group, region, onClose }) { - // The list leaves out each group's body and leadership; this - // panel fetches them for the one group it shows. - const { data: full } = useOrganization(group.id); - /* "Led by" comes from affiliations rather than a text field, so it lists real people and stays empty until they exist. */ - const leads = (full?.leadership ?? []) + const leads = (group.leadership ?? []) .map(person => person.title ? `${person.display_name} (${person.title})` : person.display_name ) @@ -566,7 +561,7 @@ function GroupDetail({ group, region, onClose }) { - + {rows.length > 0 && (