X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2FViewSonePage.java;h=0792a6fdef83f3d62f5a5497157fe34e52b2e1b5;hb=9e4db46b86d084eba9029906e779ec1d96f78ac4;hp=ba69eed025f34c165d07784e89414a36aa0426d8;hpb=fb35fd7f5f4aa4e830f6767eefbc564e4254e017;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/web/ViewSonePage.java b/src/main/java/net/pterodactylus/sone/web/ViewSonePage.java index ba69eed..0792a6f 100644 --- a/src/main/java/net/pterodactylus/sone/web/ViewSonePage.java +++ b/src/main/java/net/pterodactylus/sone/web/ViewSonePage.java @@ -17,8 +17,13 @@ package net.pterodactylus.sone.web; +import java.util.List; + +import net.pterodactylus.sone.data.Post; +import net.pterodactylus.sone.data.Reply; import net.pterodactylus.sone.data.Sone; import net.pterodactylus.util.template.Template; +import net.pterodactylus.util.template.TemplateContext; /** * Lets the user browser another Sone. @@ -36,7 +41,7 @@ public class ViewSonePage extends SoneTemplatePage { * The Sone web interface */ public ViewSonePage(Template template, WebInterface webInterface) { - super("viewSone.html", template, "Page.ViewSone.Title", webInterface); + super("viewSone.html", template, "Page.ViewSone.Title", webInterface, false); } // @@ -47,11 +52,30 @@ public class ViewSonePage extends SoneTemplatePage { * {@inheritDoc} */ @Override - protected void processTemplate(Request request, Template template) throws RedirectException { - super.processTemplate(request, template); + protected void processTemplate(Request request, TemplateContext templateContext) throws RedirectException { + super.processTemplate(request, templateContext); String soneId = request.getHttpRequest().getParam("sone"); - Sone sone = webInterface.core().getSone(soneId); - template.set("sone", sone); + Sone sone = webInterface.getCore().getSone(soneId, false); + templateContext.set("sone", sone); + } + + /** + * {@inheritDoc} + */ + @Override + protected void postProcess(Request request, TemplateContext templateContext) { + Sone sone = (Sone) templateContext.get("sone"); + if (sone == null) { + return; + } + webInterface.getCore().markSoneKnown(sone); + List posts = sone.getPosts(); + for (Post post : posts) { + webInterface.getCore().markPostKnown(post); + for (Reply reply : webInterface.getCore().getReplies(post)) { + webInterface.getCore().markReplyKnown(reply); + } + } } }