Show the latest seven non-new comics below the most recent one.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 1 Mar 2013 06:22:01 +0000 (07:22 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 1 Mar 2013 06:22:01 +0000 (07:22 +0100)
src/main/java/net/pterodactylus/rhynodge/triggers/NewComicTrigger.java

index fa3347c..0f89ddb 100644 (file)
@@ -19,6 +19,8 @@ package net.pterodactylus.rhynodge.triggers;
 
 import static com.google.common.base.Preconditions.*;
 
+import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 
 import net.pterodactylus.rhynodge.Reaction;
@@ -127,6 +129,19 @@ public class NewComicTrigger implements Trigger {
                        generateComicHtml(html, newComic);
                }
 
+               List<Comic> latestComics = new ArrayList<Comic>(mergedComicState.comics());
+               Collections.reverse(latestComics);
+               int comicCount = 0;
+               for (Comic comic : latestComics) {
+                       if (newComics.contains(comic)) {
+                               continue;
+                       }
+                       generateComicHtml(html, comic);
+                       if (++comicCount == 7) {
+                               break;
+                       }
+               }
+
                return html.append("</body>").toString();
        }