ba085eff4e
- entry: reply_to/reply_count/last_activity; reply_count bubbelt bis Root
- Hauptfeed nur Roots nach last_activity, Profil-Feed inkl. Antworten
- GET /entry/{pid}/thread (Ahnen+Antworten), GET /e/{pid} Focus-Seite
- Frontend: Antworten-Link im Feed, entry.html/entry.js Focus-Seite
- notes/migrations.md: ALTER TABLE fuer Prod
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
56 lines
1.5 KiB
JavaScript
56 lines
1.5 KiB
JavaScript
"use strict";
|
|
|
|
// pid aus dem Pfad /e/<pid>.
|
|
const pid = location.pathname.split("/")[2] || "";
|
|
|
|
document.getElementById("reply-form").addEventListener("submit", async (e) => {
|
|
e.preventDefault();
|
|
const fd = new FormData(e.target);
|
|
fd.append("reply_to", pid);
|
|
const res = await api.post("/entry/create", fd);
|
|
if (res.ok) {
|
|
e.target.reset();
|
|
document.getElementById("reply-msg").textContent = "";
|
|
load();
|
|
} else {
|
|
document.getElementById("reply-msg").textContent =
|
|
res.data.error || "Antwort fehlgeschlagen.";
|
|
}
|
|
});
|
|
|
|
async function load() {
|
|
const data = await api.get(`/entry/${pid}/thread`);
|
|
|
|
const focus = document.getElementById("focus");
|
|
if (data.error) {
|
|
focus.textContent = "Beitrag nicht gefunden";
|
|
return;
|
|
}
|
|
|
|
// Ahnenkette (Root zuerst), dann der fokussierte Beitrag.
|
|
const ancestors = document.getElementById("ancestors");
|
|
ancestors.innerHTML = "";
|
|
data.ancestors.forEach((a) => ancestors.appendChild(renderEntry(a)));
|
|
|
|
focus.innerHTML = "";
|
|
focus.appendChild(renderEntry(data.entry));
|
|
|
|
// Reply-Box nur eingeloggt zeigen.
|
|
const h = await api.get("/auth/headerbar");
|
|
document.getElementById("reply-box").hidden = !h.loggedin;
|
|
|
|
// Direkte Antworten.
|
|
const replies = document.getElementById("replies");
|
|
replies.innerHTML = "";
|
|
if (!data.replies.length) {
|
|
const p = document.createElement("p");
|
|
p.className = "muted";
|
|
p.textContent = "Noch keine Antworten.";
|
|
replies.appendChild(p);
|
|
} else {
|
|
data.replies.forEach((e) => replies.appendChild(renderEntry(e)));
|
|
}
|
|
}
|
|
|
|
load();
|