From: David ‘Bombe’ Roden Date: Thu, 25 Nov 2010 11:14:57 +0000 (+0100) Subject: Mark shown posts and replies known. X-Git-Tag: 0.3.1-RC1~26 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=533720edfdc8c59088db00fef5374c6a8f461a1a;p=Sone.git Mark shown posts and replies known. --- 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); + } + } + } + }