Files
sorsfonalak/services/frontend/src/components/forum/ThreadView.tsx
T
fecoandClaude Opus 5.5 de629a068d
CI / test (push) Successful in 3m10s
CI / build (push) Skipped
CI / deploy (push) Skipped
Forum photos, a one-row bottom menu, and the site's own question windows
Photos in posts and replies: a "Fotó" button in the new thread form and the
reply boxes. The browser makes the picture small before uploading it (1600
pixels at most, WebP, JPEG where WebP cannot be made); the forum checks it
is a still picture, strips its metadata and makes a square preview
(forum-photos/ in the storage). Five a member a day, five a post; one taken
off before sending is deleted and does not count. Under the post a row of
square previews; a click opens a viewer paged with arrows, swipes and keys.
Seen by whoever may read the thread (long public cache only for public
topics). Unsent photos go after a day, those of removed posts after a year;
removed with the account and listed in the data export. Terms and privacy
notice updated.

The forum's bottom menu keeps its five items in one row (the fifth wrapped
to a second row). On iPhones, when the keyboard goes away without the usual
tap (a photo picker opening over it), the page is put back in place instead
of the menu floating mid-screen over an empty strip.

The browser's own confirm() and prompt() windows (23 places: deleting,
revoking, blocking, muting, moderators' reasons, admin actions) are replaced
by a question window in the site's look, following the forum's light or
dark theme, with named buttons and a text box for reasons.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
2026-11-27 00:34:59 +00:00

847 lines
31 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"use client";
import Link from "next/link";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { api, errorText } from "@/lib/api";
import { type ForumPost, INTENTS, REACTIONS, type ReactionKind, type ThreadPage, ago, memberHref } from "@/lib/forum";
import { signGlyphs } from "./AuthorLine";
import { Avatar } from "./Avatar";
import { Composer } from "./Composer";
import { PostBody } from "./PostBody";
import type { LiveNotice } from "./ForumNav";
import { ReactionIcon } from "./ReactionIcon";
import { ReportForm } from "./ReportButton";
import { LinkPreviews } from "./LinkPreviews";
import { PostPhotos } from "./Photos";
import { ShareCard } from "./ShareCard";
import { TypingLine, useTypingSender, useTypingWatch } from "./typing";
import { Badge, RankBadge } from "./Badges";
import { askDialog, confirmDialog } from "@/components/Dialogs";
/** How often the open thread looks for new replies (while the page is in front). */
const POLL_MS = 30_000;
type Actions = {
busy: boolean;
react: (post: ForumPost, kind: ReactionKind | "down") => void;
replyTo: (post: ForumPost) => void;
edit: (post: ForumPost, body: string) => Promise<boolean>;
remove: (post: ForumPost) => void;
restore: (post: ForumPost) => void;
helped: (post: ForumPost) => void;
/** The author takes the shared chart off their question. */
detachShare: (post: ForumPost) => void;
/** Mute or unmute the post's author. */
mute: (post: ForumPost) => void;
};
function ReactionRow({
post,
enabled,
canDownvote,
onReact,
}: {
post: ForumPost;
enabled: boolean;
canDownvote: boolean;
onReact: Actions["react"];
}) {
const [open, setOpen] = useState(false);
const given = REACTIONS.filter((r) => post.reactions[r.kind] > 0 || post.mine === r.kind);
return (
<div className="fr-row" role="group" aria-label="Reakciók">
{given.map((r) => (
<button
key={r.kind}
type="button"
className="fr-chip"
aria-pressed={post.mine === r.kind}
aria-label={`${r.label}, ${post.reactions[r.kind]}${post.mine === r.kind ? ", a tiéd" : ""}`}
title={r.label}
disabled={!enabled}
onClick={() => onReact(post, r.kind)}
>
<ReactionIcon kind={r.kind} filled={post.mine === r.kind} />
{post.reactions[r.kind]}
</button>
))}
{enabled && (
<Popover
open={open}
onClose={() => setOpen(false)}
button={
<button
type="button"
className="fr-chip fr-add"
aria-label="Reakció hozzáadása"
aria-expanded={open}
onClick={() => setOpen((o) => !o)}
>
<svg viewBox="0 0 24 24" aria-hidden="true">
<path d="M12 6v12M6 12h12" />
</svg>
</button>
}
>
{REACTIONS.map((r) => (
<button
key={r.kind}
type="button"
role="menuitem"
className="fpop-item"
aria-pressed={post.mine === r.kind}
onClick={() => {
setOpen(false);
onReact(post, r.kind);
}}
>
<ReactionIcon kind={r.kind} size={18} filled={post.mine === r.kind} />
{r.label}
</button>
))}
</Popover>
)}
{canDownvote && enabled && (
<button
type="button"
className="fr-chip fr-down"
aria-pressed={post.mine === "down"}
aria-label="Nem visz előre"
title="Nem visz előre"
onClick={() => onReact(post, "down")}
>
<svg viewBox="0 0 24 24" aria-hidden="true">
<path d="M7 10l5 5 5-5" />
</svg>
</button>
)}
</div>
);
}
/** A small menu under a button (closes on a click elsewhere or Escape). */
function Popover({
open,
onClose,
button,
children,
align = "left",
}: {
open: boolean;
onClose: () => void;
button: React.ReactNode;
children: React.ReactNode;
align?: "left" | "right";
}) {
const box = useRef<HTMLSpanElement>(null);
useEffect(() => {
if (!open) return;
const outside = (e: MouseEvent) => {
if (box.current && !box.current.contains(e.target as Node)) onClose();
};
const escape = (e: KeyboardEvent) => {
if (e.key === "Escape") onClose();
};
document.addEventListener("mousedown", outside);
document.addEventListener("keydown", escape);
return () => {
document.removeEventListener("mousedown", outside);
document.removeEventListener("keydown", escape);
};
}, [open, onClose]);
return (
<span className="fpop-wrap" ref={box}>
{button}
{open && (
<span className={align === "right" ? "fpop fpop-right" : "fpop"} role="menu">
{children}
</span>
)}
</span>
);
}
/** The site's own mark as an avatar (the daily sky thread). */
function SiteMark({ size }: { size: number }) {
return (
<span className="av av-site" style={{ width: size, height: size }}>
<svg viewBox="0 0 64 64" width={size} height={size} aria-hidden="true">
<circle cx="32" cy="32" r="32" className="av-bg" />
<g fill="none" strokeWidth="4.5" strokeLinecap="round" className="av-site-mark">
<circle cx="32" cy="32" r="18" />
<path d="M15 43 C 26 42, 30 25, 42 21" />
</g>
</svg>
</span>
);
}
function PostCard({
post,
page,
actions,
isNew,
nested = false,
}: {
post: ForumPost;
page: ThreadPage;
actions: Actions;
isNew: boolean;
nested?: boolean;
}) {
const [editing, setEditing] = useState(false);
const [reporting, setReporting] = useState(false);
const [menu, setMenu] = useState(false);
const [showCollapsed, setShowCollapsed] = useState(false);
const [showMuted, setShowMuted] = useState(false);
const { viewer, thread, access } = page;
const writer = viewer.member !== null && !viewer.member.banned;
const starter = post.author !== null && post.author.nickname === thread.author?.nickname;
const canReact = writer && !post.own && !post.deleted && !thread.locked;
const author = post.author;
const glyphs = signGlyphs(author?.signs);
const size = post.is_opening ? 40 : nested ? 26 : 32;
if (post.deleted && !viewer.moderator) {
return (
<article className="fp fp-removed" id={`h${post.id}`}>
<span>
{post.deleted.by_moderator
? "A moderátor eltávolította ezt a hozzászólást."
: "A szerző törölte ezt a hozzászólást."}
</span>
{post.deleted.reason && <span className="hint">Ok: {post.deleted.reason}</span>}
</article>
);
}
// A muted member's post folds up; one click shows it.
if (post.muted && !showMuted) {
return (
<article className={nested ? "fp fp-muted fp-nested" : "fp fp-muted"} id={`h${post.id}`}>
<button type="button" className="fp-collapsed" onClick={() => setShowMuted(true)}>
{author?.nickname ?? "Egy tag"} hozzászólása · elnémítottad · Megjelenítés
</button>
</article>
);
}
const menuItems: { label: string; run: () => void; danger?: boolean }[] = [];
if (!post.deleted) {
if (access?.is_thread_author && !post.is_opening && !post.own && writer) {
menuItems.push({ label: post.helped ? "Mégsem segített" : "Ez segített", run: () => actions.helped(post) });
}
if (post.own && writer && !thread.locked) menuItems.push({ label: "Szerkesztés", run: () => setEditing(true) });
if (post.own && post.share && !post.share.revoked)
menuItems.push({ label: "Képlet levétele", run: () => actions.detachShare(post) });
if (post.own) menuItems.push({ label: "Törlés", run: () => actions.remove(post), danger: true });
if (viewer.logged_in && !post.own) menuItems.push({ label: "Jelentés", run: () => setReporting(true) });
if (viewer.member && !post.own && author && !post.system)
menuItems.push({
label: post.muted ? `${author.nickname} némításának feloldása` : `${author.nickname} némítása`,
run: () => actions.mute(post),
});
if (viewer.moderator && !post.own)
menuItems.push({ label: "Eltávolítás", run: () => actions.remove(post), danger: true });
} else if (viewer.moderator) {
menuItems.push({ label: "Visszaállítás (admin)", run: () => actions.restore(post) });
}
const classes = ["fp", post.is_opening && "fp-opening", nested && "fp-nested"].filter(Boolean).join(" ");
return (
<article className={classes} id={`h${post.id}`}>
<span className="fp-av">
{post.system ? (
<SiteMark size={size} />
) : author ? (
<Link href={memberHref(author.nickname)} tabIndex={-1} aria-hidden="true">
<Avatar avatar={author.avatar} size={size} online={author.online} />
</Link>
) : (
<Avatar avatar={null} size={size} />
)}
</span>
<div className="fp-head">
<span className="fp-names">
{post.system ? (
<span className="fa-name">Sorsfonalak</span>
) : author ? (
<Link href={memberHref(author.nickname)} className="fa-name">
{author.nickname}
</Link>
) : (
<span className="fa-name muted">Törölt tag</span>
)}
{post.reply_to?.nickname && nested && (
<span className="fp-replyto" title={`Válasz neki: ${post.reply_to.nickname}`}>
<svg viewBox="0 0 24 24" aria-hidden="true">
<path d="M9 14L4 9l5-5" />
<path d="M4 9h10a6 6 0 0 1 6 6v4" />
</svg>
<span className="sr-only">válasz neki:</span>
{post.reply_to.nickname}
</span>
)}
{author?.online && <span className="sr-only">(online)</span>}
{author && <RankBadge rank={author.rank} name={author.rank_name} />}
{post.system && <Badge kind="sky" />}
{author?.moderator && <Badge kind="mod" />}
{author?.founder && !nested && <Badge kind="founder" />}
{author?.listener && <Badge kind="listener" />}
{author?.supporter && <Badge kind="supporter" />}
{starter && !post.is_opening && <Badge kind="starter" />}
{isNew && <span className="fa-badge fa-badge-new">új</span>}
{glyphs && !nested && (
<span className="fp-signs sym" title={glyphs.title}>
{glyphs.text}
</span>
)}
</span>
<time
className="fp-time"
suppressHydrationWarning
dateTime={post.created_at}
title={new Date(post.created_at).toLocaleString("hu-HU", { timeZone: "Europe/Budapest" })}
>
{ago(post.created_at)}
{post.edited_at && " · szerkesztve"}
</time>
</div>
<div className="fp-content">
{post.deleted && (
<p className="fp-mod-note">
Eltávolítva{post.deleted.reason ? ` (ok: ${post.deleted.reason})` : " a szerző által"}. Csak a moderátorok
látják.
</p>
)}
{post.collapsed && !showCollapsed ? (
<button type="button" className="fp-collapsed" onClick={() => setShowCollapsed(true)}>
Sokan jelezték, hogy ez nem visz előre. Megjelenítés
</button>
) : editing ? (
<Composer
mentions
id={`szerk-${post.id}`}
label="Hozzászólás szerkesztése"
initial={post.body ?? ""}
submitLabel="Mentés"
busy={actions.busy}
autoFocus
onCancel={() => setEditing(false)}
onSubmit={async (text) => {
const ok = await actions.edit(post, text);
if (ok) setEditing(false);
return ok;
}}
/>
) : (
post.body !== null && (
<>
<PostBody text={post.body} mentions={post.mentions} hide={post.links?.map((l) => l.url) ?? []} />
{post.photos && post.photos.length > 0 && <PostPhotos photos={post.photos} />}
{post.links && post.links.length > 0 && <LinkPreviews links={post.links} />}
{post.share && <ShareCard share={post.share} />}
</>
)
)}
</div>
{!editing && (!post.deleted || menuItems.length > 0) && (
<div className="fp-actions">
{post.helped && (
<span className="fp-helped" title={`${thread.author?.nickname ?? "A szál indítója"} szerint ez segített`}>
<svg viewBox="0 0 24 24" aria-hidden="true">
<path d="M5 12.5l4.5 4.5L19 7.5" />
</svg>
Segített
</span>
)}
{!post.deleted && (
<ReactionRow
post={post}
enabled={canReact}
canDownvote={access?.can_downvote ?? false}
onReact={actions.react}
/>
)}
<span className="fp-spacer" />
{viewer.moderator && typeof post.down === "number" && post.down > 0 && (
<span className="hint" title="Nem visz előre jelzések (csak moderátoroknak)">
⌄ {post.down}
</span>
)}
{!post.deleted && access?.can_reply && writer && !post.is_opening && (
<button type="button" className="fp-reply" onClick={() => actions.replyTo(post)}>
<svg viewBox="0 0 24 24" aria-hidden="true">
<path d="M9 14L4 9l5-5" />
<path d="M4 9h10a6 6 0 0 1 6 6v4" />
</svg>
Válasz
</button>
)}
{menuItems.length > 0 && (
<Popover
open={menu}
onClose={() => setMenu(false)}
align="right"
button={
<button
type="button"
className="fp-more"
aria-label="Továbbiak"
aria-expanded={menu}
onClick={() => setMenu((m) => !m)}
>
<svg viewBox="0 0 24 24" aria-hidden="true">
<circle cx="5.5" cy="12" r="1.6" />
<circle cx="12" cy="12" r="1.6" />
<circle cx="18.5" cy="12" r="1.6" />
</svg>
</button>
}
>
{menuItems.map((item) => (
<button
key={item.label}
type="button"
role="menuitem"
className={item.danger ? "fpop-item fpop-danger" : "fpop-item"}
onClick={() => {
setMenu(false);
item.run();
}}
>
{item.label}
</button>
))}
</Popover>
)}
</div>
)}
{reporting && (
<div className="fp-report">
<ReportForm path={`/forum/posts/${post.id}/report`} onClose={() => setReporting(false)} />
</div>
)}
</article>
);
}
/** The thread page: posts, reactions, replies, read marks, new replies while open. */
export function ThreadView({ initial }: { initial: ThreadPage }) {
const [page, setPage] = useState(initial);
const [incoming, setIncoming] = useState<ThreadPage | null>(null);
const [replyTo, setReplyTo] = useState<ForumPost | null>(null);
const [busy, setBusy] = useState(false);
const [error, setError] = useState<string | null>(null);
// Where the visitor stopped reading when they opened the page.
const [readUpTo] = useState(initial.access?.last_read_post_id ?? null);
const typingNow = useTypingWatch("thread", initial.thread.id);
const imTyping = useTypingSender("thread", initial.thread.id);
const composer = useRef<HTMLDivElement>(null);
// Replying to a post: the box opens at the bottom of its branch (the
// first-level post and the replies under it); what was typed moves along.
const inline = useRef<HTMLDivElement>(null);
const draft = useRef("");
const replyBranch = replyTo ? (replyTo.parent_id ?? replyTo.id) : null;
useEffect(() => {
if (replyBranch === null) return;
const box = inline.current;
box?.scrollIntoView({ behavior: "smooth", block: "center" });
box?.querySelector("textarea")?.focus({ preventScroll: true });
}, [replyBranch, replyTo]);
const { viewer, thread, access } = page;
const member = viewer.member !== null;
const base = `/forum/threads/${thread.id}`;
const lastId = page.posts.length ? page.posts[page.posts.length - 1].id : 0;
// Mark read up to the newest post shown.
useEffect(() => {
if (!member || lastId === 0) return;
api(`${base}/read`, { body: { post_id: lastId } })
// The answers read here leave the count on the "Válaszok" tab.
.then(() => window.dispatchEvent(new Event("forum:nav")))
.catch(() => {});
}, [member, lastId, base]);
// New replies while the page is open: offered, not pushed into the text being read.
const poll = useCallback(async () => {
if (document.visibilityState !== "visible" || thread.deleted) return;
try {
const fresh = await api<ThreadPage>(base);
const freshLast = fresh.posts.length ? fresh.posts[fresh.posts.length - 1].id : 0;
if (freshLast > lastId) setIncoming(fresh);
} catch {
/* a missed poll is retried later */
}
}, [base, lastId, thread.deleted]);
useEffect(() => {
const timer = window.setInterval(poll, POLL_MS);
// The live connection rings for this thread: look at once.
const live = (e: Event) => {
const notice = (e as CustomEvent<LiveNotice>).detail;
if (notice.t === "thread" && notice.id === thread.id) void poll();
};
window.addEventListener("forum:live", live);
return () => {
window.clearInterval(timer);
window.removeEventListener("forum:live", live);
};
}, [poll, thread.id]);
const newCount = incoming ? incoming.posts.filter((p) => p.id > lastId && !p.own).length : 0;
async function run<T>(work: () => Promise<T>): Promise<T | null> {
setBusy(true);
setError(null);
try {
return await work();
} catch (e) {
setError(errorText(e));
return null;
} finally {
setBusy(false);
}
}
const replacePost = useCallback((post: ForumPost) => {
setPage((p) => ({ ...p, posts: p.posts.map((x) => (x.id === post.id ? post : x)) }));
}, []);
const reload = useCallback(async () => {
const fresh = await api<ThreadPage>(base);
setPage(fresh);
setIncoming(null);
}, [base]);
const actions: Actions = {
busy,
react: (post, kind) =>
void run(async () => {
const updated =
post.mine === kind
? await api<ForumPost>(`/forum/posts/${post.id}/reaction`, { method: "DELETE" })
: await api<ForumPost>(`/forum/posts/${post.id}/reaction`, { method: "PUT", body: { kind } });
replacePost(updated);
}),
replyTo: (post) => setReplyTo(post),
edit: async (post, body) => {
const updated = await run(() => api<ForumPost>(`/forum/posts/${post.id}`, { method: "PATCH", body: { body } }));
if (updated) replacePost(updated);
return updated !== null;
},
remove: async (post) => {
let reason: string | null = null;
if (post.own) {
const ok = await confirmDialog({ title: "Törlöd a hozzászólásodat?", confirm: "Törlés", danger: true });
if (!ok) return;
} else {
reason = await askDialog({
title: "Eltávolítod a hozzászólást?",
text: "Az indoklás a hozzászólás helyén látszik.",
label: "Miért távolítod el?",
required: true,
confirm: "Eltávolítás",
danger: true,
});
if (!reason) return;
}
void run(async () => {
await api(`/forum/posts/${post.id}`, { method: "DELETE", body: { reason } });
await reload();
});
},
restore: (post) =>
void run(async () => {
await api(`/forum/posts/${post.id}/restore`, { method: "POST" });
await reload();
}),
detachShare: async (post) => {
const ok = await confirmDialog({
title: "Leveszed a csatolt képletet?",
text: "A kártya eltűnik, és a link sem működik többé.",
confirm: "Levétel",
danger: true,
});
if (!ok) return;
void run(async () => {
await api(`/forum/posts/${post.id}/share`, { method: "DELETE" });
await reload();
});
},
mute: async (post) => {
const nickname = post.author?.nickname;
if (!nickname) return;
if (
!post.muted &&
!(await confirmDialog({
title: `Elnémítod ${nickname} tagot?`,
text: "A szálai eltűnnek a listáidból, a hozzászólásai összecsukva látszanak, és nem kapsz értesítést tőle. Ő erről nem tud. A beállításoknál bármikor feloldhatod.",
confirm: "Elnémítás",
}))
)
return;
void run(async () => {
await api(`/forum/members/${encodeURIComponent(nickname)}/mute`, { method: post.muted ? "DELETE" : "PUT" });
await reload();
});
},
helped: (post) =>
void run(async () => {
const updated = await api<ForumPost>(`/forum/posts/${post.id}/helped`, {
method: post.helped ? "DELETE" : "PUT",
});
replacePost(updated);
}),
};
/** A first-level reply (the box at the bottom), or one to `replyTo` (the box in its branch). */
async function sendReply(text: string, to: ForumPost | null, photos: string[] = []): Promise<boolean> {
const post = await run(() =>
api<ForumPost>(`${base}/posts`, { body: { body: text, parent_id: to?.id ?? null, photos } }),
);
if (!post) return false;
if (to) {
draft.current = "";
setReplyTo(null);
}
await reload().catch(() => setPage((p) => ({ ...p, posts: [...p.posts, post] })));
requestAnimationFrame(() => document.getElementById(`h${post.id}`)?.scrollIntoView({ block: "center" }));
return true;
}
async function toggleFollow() {
const following = access?.following ?? false;
await run(() => api(`${base}/follow`, { method: following ? "DELETE" : "PUT" }));
setPage((p) => (p.access ? { ...p, access: { ...p.access, following: !following } } : p));
}
async function moderateThread(change: { locked?: boolean; pinned?: boolean }) {
await run(() => api(base, { method: "PATCH", body: change }));
await reload();
}
async function removeThread() {
const reason = await askDialog({
title: "Eltávolítod az egész szálat?",
text: "Az indoklás látszik a szál helyén.",
label: "Miért távolítod el?",
required: true,
confirm: "Eltávolítás",
danger: true,
});
if (!reason) return;
await run(() => api(base, { method: "DELETE", body: { reason } }));
await reload();
}
const opening = page.posts.find((p) => p.is_opening);
const replies = useMemo(() => page.posts.filter((p) => !p.is_opening), [page.posts]);
const tops = replies.filter((p) => p.parent_id === null);
const childrenOf = (id: number) => replies.filter((p) => p.parent_id === id);
// "Itt hagytad abba": before the first post by someone else after the last visit.
const firstUnread = readUpTo !== null ? (replies.find((p) => p.id > readUpTo && !p.own)?.id ?? null) : null;
const unreadCount = firstUnread !== null ? replies.filter((p) => p.id >= firstUnread && !p.own).length : 0;
const topOf = (id: number) => {
const p = replies.find((x) => x.id === id);
return p?.parent_id ?? id;
};
const markerTop = firstUnread !== null ? topOf(firstUnread) : null;
const intent = thread.intent ? INTENTS[thread.intent] : null;
const starter = thread.author?.nickname ?? "A szál indítója";
return (
<div className="ftv">
<nav className="forum-crumbs" aria-label="Morzsamenü">
<Link href="/forum">Fórum</Link>
<span aria-hidden="true">›</span>
<Link href={`/forum/${thread.topic.slug}`}>{thread.topic.name}</Link>
{thread.topic.visibility !== "public" && (
<span
className="ftv-private"
title={
thread.topic.visibility === "members"
? "Csak belépett tagok látják, a keresők sem"
: "Zárt kör: csak a jóváhagyott tagok látják"
}
>
<svg viewBox="0 0 24 24" aria-hidden="true">
<rect x="5" y="11" width="14" height="9" rx="2" />
<path d="M8 11V8a4 4 0 0 1 8 0v3" />
</svg>
{thread.topic.visibility === "members" ? "csak tagoknak" : "zárt kör"}
</span>
)}
</nav>
<div className="ftv-toolbar">
{member && access && (
<button type="button" className="btn btn-sm" aria-pressed={access.following} onClick={toggleFollow}>
{access.following ? "Követem ✓" : "Követem"}
</button>
)}
{viewer.moderator && !thread.deleted && (
<details className="ftv-mod">
<summary className="btn btn-sm btn-ghost">Moderálás</summary>
<div className="ftv-mod-menu">
<button type="button" onClick={() => moderateThread({ locked: !thread.locked })}>
{thread.locked ? "Szál feloldása" : "Szál lezárása"}
</button>
<button type="button" onClick={() => moderateThread({ pinned: !thread.pinned })}>
{thread.pinned ? "Kitűzés levétele" : "Kitűzés"}
</button>
<button type="button" className="danger" onClick={removeThread}>
Szál eltávolítása
</button>
</div>
</details>
)}
</div>
{thread.deleted ? (
<div className="fp fp-removed">
<span>A moderátor eltávolította ezt a szálat.</span>
{thread.deleted.reason && <span className="hint">Ok: {thread.deleted.reason}</span>}
</div>
) : null}
<h1 className="ftv-title">
{thread.pinned && <span className="ft-pin">Kitűzve</span>}
{thread.locked && <span className="ft-pin">Lezárva</span>}
{thread.title}
</h1>
{intent && (
<p className="ftv-intent-line">
<span className={`ft-intent ft-intent-${thread.intent}`}>{intent.label}</span>
{thread.intent === "listen"
? "tanács helyett elég, ha jelen vagy, és leírod, ha veled is történt hasonló"
: `${starter} kíváncsi a véleményetekre és a tapasztalataitokra`}
</p>
)}
{opening && <PostCard post={opening} page={page} actions={actions} isNew={false} />}
{(replies.length > 0 || !thread.deleted) && (
<div className="ftv-count">
<h2>{replies.filter((p) => !p.deleted).length} válasz</h2>
<span className="hint">időrendben</span>
</div>
)}
{tops.map((top) => (
<div key={top.id} className="ftv-branch">
{markerTop === top.id && (
<div className="ftv-marker" role="separator" aria-label={`Itt hagytad abba, ${unreadCount} új`}>
<span>Itt hagytad abba · {unreadCount} új</span>
</div>
)}
<PostCard
post={top}
page={page}
actions={actions}
isNew={firstUnread !== null && top.id >= firstUnread && !top.own}
/>
{childrenOf(top.id).length > 0 && (
<div className="ftv-children">
{childrenOf(top.id).map((child) => (
<PostCard
key={child.id}
nested
post={child}
page={page}
actions={actions}
isNew={firstUnread !== null && child.id >= firstUnread && !child.own}
/>
))}
</div>
)}
{replyTo && replyBranch === top.id && (
<div className="ftv-inline" ref={inline}>
<p className="ftv-replyto">
<svg viewBox="0 0 24 24" aria-hidden="true">
<path d="M9 14L4 9l5-5" />
<path d="M4 9h10a6 6 0 0 1 6 6v4" />
</svg>
Válasz neki: <strong>{replyTo.author?.nickname ?? "Törölt tag"}</strong>
</p>
<Composer
key={top.id}
mentions
photos
onTyping={imTyping}
id={`valasz-${top.id}`}
label={`Válasz neki: ${replyTo.author?.nickname ?? "Törölt tag"}`}
placeholder="Írd meg a válaszod…"
initial={draft.current}
onChange={(text) => {
draft.current = text;
}}
busy={busy}
onSubmit={(text, photos) => sendReply(text, replyTo, photos)}
onCancel={() => {
draft.current = "";
setReplyTo(null);
}}
/>
</div>
)}
</div>
))}
{newCount > 0 && (
<button
type="button"
className="ftv-incoming"
onClick={() => incoming && (setPage(incoming), setIncoming(null))}
>
{newCount === 1 ? "1 új válasz érkezett" : `${newCount} új válasz érkezett`}
</button>
)}
{error && (
<p className="msg msg-error" role="alert">
{error}
</p>
)}
<TypingLine text={typingNow} />
<div className="ftv-compose" id="valasz" ref={composer}>
{thread.deleted ? null : !viewer.logged_in ? (
<p className="ftv-gate">
<Link href={`/belepes?vissza=/forum/szal/${thread.id}-${thread.slug}`}>Lépj be</Link>, hogy hozzászólhass.
</p>
) : viewer.needs_nickname ? (
<p className="ftv-gate">
<Link href={`/forum/beallitasok?vissza=/forum/szal/${thread.id}-${thread.slug}`}>Válassz álnevet</Link>,
hogy hozzászólhass.
</p>
) : viewer.member?.banned ? (
<p className="ftv-gate">Most nem írhatsz a fórumba.</p>
) : !access?.can_reply ? (
<p className="ftv-gate">
{thread.topic.archived
? "Ez a téma archivált: olvasható, de új hozzászólás nem írható."
: "Ez a szál le van zárva, új hozzászólás nem írható."}
</p>
) : (
<>
<Composer
mentions
photos
onTyping={imTyping}
id="valasz-szoveg"
label="Válaszod"
placeholder={thread.topic.listening ? "Írd le, ami benned van…" : "Írd meg a válaszod…"}
busy={busy}
onSubmit={(text, photos) => sendReply(text, null, photos)}
/>
</>
)}
</div>
</div>
);
}