From 533720edfdc8c59088db00fef5374c6a8f461a1a Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 25 Nov 2010 12:14:57 +0100 Subject: [PATCH] Mark shown posts and replies known. --- .../java/net/pterodactylus/sone/web/IndexPage.java | 16 ++++++++++++++++ .../java/net/pterodactylus/sone/web/ViewPostPage.java | 13 +++++++++++++ .../java/net/pterodactylus/sone/web/ViewSonePage.java | 19 +++++++++++++++++++ 3 files changed, 48 insertions(+) diff --git a/src/main/java/net/pterodactylus/sone/web/IndexPage.java b/src/main/java/net/pterodactylus/sone/web/IndexPage.java index 00ccc35..7562526 100644 --- a/src/main/java/net/pterodactylus/sone/web/IndexPage.java +++ b/src/main/java/net/pterodactylus/sone/web/IndexPage.java @@ -22,6 +22,7 @@ import java.util.Collections; 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; @@ -66,4 +67,19 @@ public class IndexPage extends SoneTemplatePage { template.set("posts", allPosts); } + /** + * {@inheritDoc} + */ + @Override + protected void postProcess(Request request, Template template) { + @SuppressWarnings("unchecked") + List posts = (List) template.get("posts"); + for (Post post : posts) { + webInterface.getCore().markPostKnown(post); + for (Reply reply : webInterface.getCore().getReplies(post)) { + webInterface.getCore().markReplyKnown(reply); + } + } + } + } diff --git a/src/main/java/net/pterodactylus/sone/web/ViewPostPage.java b/src/main/java/net/pterodactylus/sone/web/ViewPostPage.java index 9bc28fa..3bc3b36 100644 --- a/src/main/java/net/pterodactylus/sone/web/ViewPostPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ViewPostPage.java @@ -18,6 +18,7 @@ package net.pterodactylus.sone.web; import net.pterodactylus.sone.data.Post; +import net.pterodactylus.sone.data.Reply; import net.pterodactylus.util.template.Template; /** @@ -54,4 +55,16 @@ public class ViewPostPage extends SoneTemplatePage { template.set("post", post); } + /** + * {@inheritDoc} + */ + @Override + protected void postProcess(Request request, Template template) { + Post post = (Post) template.get("post"); + webInterface.getCore().markPostKnown(post); + for (Reply reply : webInterface.getCore().getReplies(post)) { + webInterface.getCore().markReplyKnown(reply); + } + } + } diff --git a/src/main/java/net/pterodactylus/sone/web/ViewSonePage.java b/src/main/java/net/pterodactylus/sone/web/ViewSonePage.java index 8b88f2e..d933bc7 100644 --- a/src/main/java/net/pterodactylus/sone/web/ViewSonePage.java +++ b/src/main/java/net/pterodactylus/sone/web/ViewSonePage.java @@ -17,6 +17,10 @@ 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; @@ -54,4 +58,19 @@ public class ViewSonePage extends SoneTemplatePage { template.set("sone", sone); } + /** + * {@inheritDoc} + */ + @Override + protected void postProcess(Request request, Template template) { + Sone sone = (Sone) template.get("sone"); + List posts = sone.getPosts(); + for (Post post : posts) { + webInterface.getCore().markPostKnown(post); + for (Reply reply : webInterface.getCore().getReplies(post)) { + webInterface.getCore().markReplyKnown(reply); + } + } + } + } -- 2.7.4