X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fnotify%2FListNotificationFilters.java;h=813b82d7176a72ebacf7d1a3011a7cd972b3ee9e;hp=c4bc72850af68d33e2eb4509c1a5e77bf594bce9;hb=c0e02c61736ad21287f2f8ce706946594e81dbac;hpb=a9e8b617d4a85bcb832b5ca15ba6dd2a9d08925f diff --git a/src/main/java/net/pterodactylus/sone/notify/ListNotificationFilters.java b/src/main/java/net/pterodactylus/sone/notify/ListNotificationFilters.java index c4bc728..813b82d 100644 --- a/src/main/java/net/pterodactylus/sone/notify/ListNotificationFilters.java +++ b/src/main/java/net/pterodactylus/sone/notify/ListNotificationFilters.java @@ -49,28 +49,22 @@ public class ListNotificationFilters { */ public static List filterNotifications(List notifications, Sone currentSone) { ListNotification newPostNotification = getNotification(notifications, "new-post-notification", Post.class); - System.out.println("Found new-post-notification with " + ((newPostNotification != null) ? newPostNotification.getElements().size() : -1) + " posts."); if (newPostNotification != null) { ListNotification filteredNotification = filterNewPostNotification(newPostNotification, currentSone); int notificationIndex = notifications.indexOf(newPostNotification); if (filteredNotification == null) { - System.out.println("Removing notification."); notifications.remove(notificationIndex); } else { - System.out.println("Replacing Notification."); notifications.set(notificationIndex, filteredNotification); } } ListNotification newReplyNotification = getNotification(notifications, "new-replies-notification", Reply.class); - System.out.println("Found new-reply-notification with " + ((newReplyNotification != null) ? newReplyNotification.getElements().size() : -1) + " replies."); if (newReplyNotification != null) { ListNotification filteredNotification = filterNewReplyNotification(newReplyNotification, currentSone); int notificationIndex = notifications.indexOf(newReplyNotification); if (filteredNotification == null) { - System.out.println("Removing Notification."); notifications.remove(notificationIndex); } else { - System.out.println("Replacing Notification."); notifications.set(notificationIndex, filteredNotification); } } @@ -96,13 +90,13 @@ public class ListNotificationFilters { } List newPosts = new ArrayList(); for (Post post : newPostNotification.getElements()) { - System.out.println("Checking Post: " + post); if (currentSone.hasFriend(post.getSone().getId()) || currentSone.equals(post.getSone())) { - System.out.println(" CS.hF: " + currentSone.hasFriend(post.getSone().getId())); - System.out.println(" CS.e:" + currentSone.equals(post.getSone())); newPosts.add(post); } } + if (newPosts.isEmpty()) { + return null; + } if (newPosts.size() == newPostNotification.getElements().size()) { return newPostNotification; } @@ -131,13 +125,13 @@ public class ListNotificationFilters { } List newReplies = new ArrayList(); for (Reply reply : newReplyNotification.getElements()) { - System.out.println("Checking Reply: " + reply); if (currentSone.hasFriend(reply.getPost().getSone().getId()) || currentSone.equals(reply.getPost().getSone())) { - System.out.println(" CS.hF: " + currentSone.hasFriend(reply.getPost().getSone().getId())); - System.out.println(" CS.e: " + currentSone.equals(reply.getPost().getSone())); newReplies.add(reply); } } + if (newReplies.isEmpty()) { + return null; + } if (newReplies.size() == newReplyNotification.getElements().size()) { return newReplyNotification; }