Forum: answers to me as the only count, reply box in the branch, keyboard-safe inputs
- The "Követett" tab becomes "Válaszok": its count is the unread answers to the member (a reply to their post, a first-level reply in their thread, or a post naming them), listed on /forum/valaszok with "Mind olvasott"; the followed threads are its second view. The other counts are gone from the menu; listeners see the waiting threads on their card on the front page. - Replying to a post opens the box at the bottom of its branch and scrolls there; another branch moves it (with the text typed so far). - Phones: while typing, the forum's bottom menu and floating bars step aside and the box with its send button is scrolled above the keyboard (KeyboardSafe, site-wide; Android resizes the page for the keyboard). - The "Meghallgató" badge is now "Kísérő", with a new icon. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -405,6 +405,17 @@ export function ThreadView({ initial }: { initial: ThreadPage }) {
|
||||
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}`;
|
||||
@@ -414,7 +425,10 @@ export function ThreadView({ initial }: { initial: ThreadPage }) {
|
||||
// Mark read up to the newest post shown.
|
||||
useEffect(() => {
|
||||
if (!member || lastId === 0) return;
|
||||
api(`${base}/read`, { body: { post_id: lastId } }).catch(() => {});
|
||||
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.
|
||||
@@ -477,10 +491,7 @@ export function ThreadView({ initial }: { initial: ThreadPage }) {
|
||||
: await api<ForumPost>(`/forum/posts/${post.id}/reaction`, { method: "PUT", body: { kind } });
|
||||
replacePost(updated);
|
||||
}),
|
||||
replyTo: (post) => {
|
||||
setReplyTo(post);
|
||||
composer.current?.scrollIntoView({ behavior: "smooth", block: "center" });
|
||||
},
|
||||
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);
|
||||
@@ -513,12 +524,14 @@ export function ThreadView({ initial }: { initial: ThreadPage }) {
|
||||
}),
|
||||
};
|
||||
|
||||
async function sendReply(text: string): Promise<boolean> {
|
||||
const post = await run(() =>
|
||||
api<ForumPost>(`${base}/posts`, { body: { body: text, parent_id: replyTo?.id ?? null } }),
|
||||
);
|
||||
/** 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): Promise<boolean> {
|
||||
const post = await run(() => api<ForumPost>(`${base}/posts`, { body: { body: text, parent_id: to?.id ?? null } }));
|
||||
if (!post) return false;
|
||||
setReplyTo(null);
|
||||
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;
|
||||
@@ -662,6 +675,35 @@ export function ThreadView({ initial }: { initial: ThreadPage }) {
|
||||
))}
|
||||
</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
|
||||
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) => sendReply(text, replyTo)}
|
||||
onCancel={() => {
|
||||
draft.current = "";
|
||||
setReplyTo(null);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
|
||||
@@ -699,19 +741,6 @@ export function ThreadView({ initial }: { initial: ThreadPage }) {
|
||||
<p className="ftv-gate">Ez a szál le van zárva, új hozzászólás nem írható.</p>
|
||||
) : (
|
||||
<>
|
||||
{replyTo && (
|
||||
<p className="ftv-replyto">
|
||||
Válasz neki: <strong>{replyTo.author?.nickname ?? "Törölt tag"}</strong>
|
||||
<button
|
||||
type="button"
|
||||
className="fp-link"
|
||||
onClick={() => setReplyTo(null)}
|
||||
aria-label="Válasz visszavonása"
|
||||
>
|
||||
×
|
||||
</button>
|
||||
</p>
|
||||
)}
|
||||
<Composer
|
||||
mentions
|
||||
onTyping={imTyping}
|
||||
@@ -719,7 +748,7 @@ export function ThreadView({ initial }: { initial: ThreadPage }) {
|
||||
label="Válaszod"
|
||||
placeholder={thread.topic.listening ? "Írd le, ami benned van…" : "Írd meg a válaszod…"}
|
||||
busy={busy}
|
||||
onSubmit={sendReply}
|
||||
onSubmit={(text) => sendReply(text, null)}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user