Add notifications for Sones that are rescued.
[Sone.git] / src / main / java / net / pterodactylus / sone / web / WebInterface.java
index db1880b..441e323 100644 (file)
@@ -119,6 +119,12 @@ public class WebInterface implements CoreListener {
        /** The “new reply” notification. */
        private final ListNotification<Reply> newReplyNotification;
 
+       /** The “rescuing Sone” notification. */
+       private final ListNotification<Sone> rescuingSonesNotification;
+
+       /** The “Sone rescued” notification. */
+       private final ListNotification<Sone> sonesRescuedNotification;
+
        /**
         * Creates a new web interface.
         *
@@ -158,6 +164,12 @@ public class WebInterface implements CoreListener {
 
                Template newReplyNotificationTemplate = templateFactory.createTemplate(createReader("/templates/notify/newReplyNotification.html"));
                newReplyNotification = new ListNotification<Reply>("new-replies-notification", "replies", newReplyNotificationTemplate);
+
+               Template rescuingSonesTemplate = templateFactory.createTemplate(createReader("/templates/notify/rescuingSonesNotification.html"));
+               rescuingSonesNotification = new ListNotification<Sone>("sones-being-rescued-notification", "sones", rescuingSonesTemplate);
+
+               Template sonesRescuedTemplate = templateFactory.createTemplate(createReader("/templates/notify/sonesRescuedNotification.html"));
+               sonesRescuedNotification = new ListNotification<Sone>("sones-rescued-notification", "sones", sonesRescuedTemplate);
        }
 
        //
@@ -387,6 +399,25 @@ public class WebInterface implements CoreListener {
         * {@inheritDoc}
         */
        @Override
+       public void rescuingSone(Sone sone) {
+               rescuingSonesNotification.add(sone);
+               notificationManager.addNotification(rescuingSonesNotification);
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       public void rescuedSone(Sone sone) {
+               rescuingSonesNotification.remove(sone);
+               sonesRescuedNotification.add(sone);
+               notificationManager.addNotification(sonesRescuedNotification);
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       @Override
        public void newSoneFound(Sone sone) {
                newSoneNotification.add(sone);
                notificationManager.addNotification(newSoneNotification);
@@ -419,9 +450,6 @@ public class WebInterface implements CoreListener {
        @Override
        public void markSoneKnown(Sone sone) {
                newSoneNotification.remove(sone);
-               if (newSoneNotification.isEmpty()) {
-                       newSoneNotification.dismiss();
-               }
        }
 
        /**
@@ -430,9 +458,6 @@ public class WebInterface implements CoreListener {
        @Override
        public void markPostKnown(Post post) {
                newPostNotification.remove(post);
-               if (newPostNotification.isEmpty()) {
-                       newPostNotification.dismiss();
-               }
        }
 
        /**
@@ -441,9 +466,6 @@ public class WebInterface implements CoreListener {
        @Override
        public void markReplyKnown(Reply reply) {
                newReplyNotification.remove(reply);
-               if (newReplyNotification.isEmpty()) {
-                       newReplyNotification.dismiss();
-               }
        }
 
        /**