Mark shown posts and replies known.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 25 Nov 2010 11:14:57 +0000 (12:14 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 25 Nov 2010 11:14:57 +0000 (12:14 +0100)
src/main/java/net/pterodactylus/sone/web/IndexPage.java
src/main/java/net/pterodactylus/sone/web/ViewPostPage.java
src/main/java/net/pterodactylus/sone/web/ViewSonePage.java

index 00ccc35..7562526 100644 (file)
@@ -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<Post> posts = (List<Post>) template.get("posts");
+               for (Post post : posts) {
+                       webInterface.getCore().markPostKnown(post);
+                       for (Reply reply : webInterface.getCore().getReplies(post)) {
+                               webInterface.getCore().markReplyKnown(reply);
+                       }
+               }
+       }
+
 }
index 9bc28fa..3bc3b36 100644 (file)
@@ -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);
+               }
+       }
+
 }
index 8b88f2e..d933bc7 100644 (file)
 
 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<Post> posts = sone.getPosts();
+               for (Post post : posts) {
+                       webInterface.getCore().markPostKnown(post);
+                       for (Reply reply : webInterface.getCore().getReplies(post)) {
+                               webInterface.getCore().markReplyKnown(reply);
+                       }
+               }
+       }
+
 }