♻️ Extract handler for new remote posts
[Sone.git] / src / main / java / net / pterodactylus / sone / web / WebInterface.java
index bcc7a11..4ed49df 100644 (file)
@@ -157,9 +157,6 @@ public class WebInterface implements SessionProvider {
        private final MetricRegistry metricRegistry;
        private final Translation translation;
 
-       /** The “new Sone” notification. */
-       private final ListNotification<Sone> newSoneNotification;
-
        /** The “new post” notification. */
        private final ListNotification<Post> newPostNotification;
 
@@ -233,9 +230,6 @@ public class WebInterface implements SessionProvider {
                templateContextFactory.addTemplateObject("formPassword", formPassword);
 
                /* create notifications. */
-               Template newSoneNotificationTemplate = loaders.loadTemplate("/templates/notify/newSoneNotification.html");
-               newSoneNotification = new ListNotification<>("new-sone-notification", "sones", newSoneNotificationTemplate, false);
-
                Template newPostNotificationTemplate = loaders.loadTemplate("/templates/notify/newPostNotification.html");
                newPostNotification = new ListNotification<>("new-post-notification", "posts", newPostNotificationTemplate, false);
 
@@ -690,20 +684,6 @@ public class WebInterface implements SessionProvider {
        //
 
        /**
-        * Notifies the web interface that a new {@link Sone} was found.
-        *
-        * @param newSoneFoundEvent
-        *            The event
-        */
-       @Subscribe
-       public void newSoneFound(NewSoneFoundEvent newSoneFoundEvent) {
-               newSoneNotification.add(newSoneFoundEvent.getSone());
-               if (!hasFirstStartNotification()) {
-                       notificationManager.addNotification(newSoneNotification);
-               }
-       }
-
-       /**
         * Notifies the web interface that a new {@link Post} was found.
         *
         * @param newPostFoundEvent
@@ -715,17 +695,15 @@ public class WebInterface implements SessionProvider {
                boolean isLocal = post.getSone().isLocal();
                if (isLocal) {
                        localPostNotification.add(post);
-               } else {
-                       newPostNotification.add(post);
                }
                if (!hasFirstStartNotification()) {
-                       notificationManager.addNotification(isLocal ? localPostNotification : newPostNotification);
+                       if (isLocal) {
+                               notificationManager.addNotification(localPostNotification);
+                       }
                        if (!getMentionedSones(post.getText()).isEmpty() && !isLocal) {
                                mentionNotification.add(post);
                                notificationManager.addNotification(mentionNotification);
                        }
-               } else {
-                       getCore().markPostKnown(post);
                }
        }
 
@@ -755,17 +733,6 @@ public class WebInterface implements SessionProvider {
                }
        }
 
-       /**
-        * Notifies the web interface that a {@link Sone} was marked as known.
-        *
-        * @param markSoneKnownEvent
-        *            The event
-        */
-       @Subscribe
-       public void markSoneKnown(MarkSoneKnownEvent markSoneKnownEvent) {
-               newSoneNotification.remove(markSoneKnownEvent.getSone());
-       }
-
        @Subscribe
        public void markPostKnown(MarkPostKnownEvent markPostKnownEvent) {
                removePost(markPostKnownEvent.getPost());
@@ -777,11 +744,6 @@ public class WebInterface implements SessionProvider {
        }
 
        @Subscribe
-       public void soneRemoved(SoneRemovedEvent soneRemovedEvent) {
-               newSoneNotification.remove(soneRemovedEvent.getSone());
-       }
-
-       @Subscribe
        public void postRemoved(PostRemovedEvent postRemovedEvent) {
                removePost(postRemovedEvent.getPost());
        }