// DocsSessionIndex.jsx — v0.19.0 / roadmap item #30. // // Per-session index page at `/docs/sessions/:nnnn`. Lists every // transcript published under the session's NNNN/ folder, linked to // the per-transcript view. // // The transcript list comes from `/api/docs/sessions/:nnnn/index`, // which the framework derives via the gitea contents API (see // backend/app/docs_sessions.fetch_session_index). We also read the // session's `title` from the manifest fetch so the page header // matches the flyout nav entry. import { useEffect, useState, useCallback } from 'react' import { Link, useParams } from 'react-router-dom' import { getSessionsManifest, getSessionIndex } from '../api.js' import { EVENTS, track } from '../lib/analytics' export default function DocsSessionIndex() { const { nnnn } = useParams() const [title, setTitle] = useState('') const [files, setFiles] = useState([]) const [status, setStatus] = useState('loading') // loading | ok | notfound | error const [reloadTick, setReloadTick] = useState(0) useEffect(() => { track(EVENTS.DOC_VIEWED, { section: `sessions/${nnnn}` }) }, [nnnn]) // Title from manifest — cheap, manifest is cached server-side. useEffect(() => { let active = true getSessionsManifest() .then(payload => { if (!active) return const entry = payload && payload[nnnn] setTitle((entry && entry.title) || '') }) .catch(() => { // Title is decorative; failure to load just leaves the header // showing the bare NNNN. The transcript list fetch below is // the load-bearing one. }) return () => { active = false } }, [nnnn]) // File list from the per-session index endpoint. useEffect(() => { let active = true setStatus('loading') getSessionIndex(nnnn) .then(payload => { if (!active) return setFiles((payload && payload.files) || []) setStatus('ok') }) .catch(e => { if (!active) return if (e.status === 404) { setStatus('notfound') } else { setStatus('error') } }) return () => { active = false } }, [nnnn, reloadTick]) const retry = useCallback(() => setReloadTick(t => t + 1), []) const header = title ? `${nnnn} — ${title}` : `Session ${nnnn}` return (

{header}

{status === 'loading' &&

Loading…

} {status === 'notfound' && (

No transcripts have been published for this session yet.{' '} About sessions

)} {status === 'error' && (

Couldn't reach the session-history repo.

)} {status === 'ok' && files.length === 0 && (

This session has no transcripts published.

)} {status === 'ok' && files.length > 0 && ( )}
) }