X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2FSearchPage.java;h=db29fd29257c83cd686834fa565a7a3180525422;hb=414ee1b03f7155ccb5049ede303dd01020ddcd94;hp=320e7cd3bf4034863dae1e92a669a153f4542feb;hpb=45803a1c678d6811f7bbf85d50c79844031be0f0;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/web/SearchPage.java b/src/main/java/net/pterodactylus/sone/web/SearchPage.java index 320e7cd..db29fd2 100644 --- a/src/main/java/net/pterodactylus/sone/web/SearchPage.java +++ b/src/main/java/net/pterodactylus/sone/web/SearchPage.java @@ -131,7 +131,7 @@ public class SearchPage extends SoneTemplatePage { redirectIfNotNull(getImageId(phrase), "imageBrowser.html?image="); } - Set sones = webInterface.getCore().getSones(); + Collection sones = webInterface.getCore().getSones(); Collection> soneHits = getHits(sones, phrases, SoneStringGenerator.COMPLETE_GENERATOR); Collection> postHits = hitCache.getUnchecked(phrases); @@ -310,7 +310,7 @@ public class SearchPage extends SoneTemplatePage { */ private String getSoneId(String phrase) { String soneId = phrase.startsWith("sone://") ? phrase.substring(7) : phrase; - return (webInterface.getCore().getSone(soneId) != null) ? soneId : null; + return (webInterface.getCore().getSone(soneId).isPresent()) ? soneId : null; } /** @@ -354,7 +354,7 @@ public class SearchPage extends SoneTemplatePage { */ private String getAlbumId(String phrase) { String albumId = phrase.startsWith("album://") ? phrase.substring(8) : phrase; - return (webInterface.getCore().getAlbum(albumId, false) != null) ? albumId : null; + return webInterface.getCore().getAlbum(albumId).isPresent() ? albumId : null; } /** @@ -367,7 +367,7 @@ public class SearchPage extends SoneTemplatePage { */ private String getImageId(String phrase) { String imageId = phrase.startsWith("image://") ? phrase.substring(8) : phrase; - return (webInterface.getCore().getImage(imageId, false) != null) ? imageId : null; + return webInterface.getCore().getImage(imageId).isPresent() ? imageId : null; } /** @@ -467,7 +467,7 @@ public class SearchPage extends SoneTemplatePage { if (post.getRecipient().isPresent()) { postString.append(' ').append(SoneStringGenerator.NAME_GENERATOR.generateString(post.getRecipient().get())); } - for (PostReply reply : Collections2.filter(webInterface.getCore().getReplies(post), Reply.FUTURE_REPLY_FILTER)) { + for (PostReply reply : Collections2.filter(webInterface.getCore().getReplies(post.getId()), Reply.FUTURE_REPLY_FILTER)) { postString.append(' ').append(SoneStringGenerator.NAME_GENERATOR.generateString(reply.getSone())); postString.append(' ').append(reply.getText()); } @@ -581,7 +581,7 @@ public class SearchPage extends SoneTemplatePage { @Override public boolean apply(Hit hit) { - return hit.getScore() > 0; + return (hit == null) ? false : hit.getScore() > 0; } };