From: David ‘Bombe’ Roden Date: Fri, 1 Mar 2013 06:22:01 +0000 (+0100) Subject: Show the latest seven non-new comics below the most recent one. X-Git-Tag: v2~303 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=74bbe79111f63cda9baca99d8122a73c335ecfe1;p=rhynodge.git Show the latest seven non-new comics below the most recent one. --- diff --git a/src/main/java/net/pterodactylus/rhynodge/triggers/NewComicTrigger.java b/src/main/java/net/pterodactylus/rhynodge/triggers/NewComicTrigger.java index fa3347c..0f89ddb 100644 --- a/src/main/java/net/pterodactylus/rhynodge/triggers/NewComicTrigger.java +++ b/src/main/java/net/pterodactylus/rhynodge/triggers/NewComicTrigger.java @@ -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 latestComics = new ArrayList(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("").toString(); }