Remove mention notifications if elements are removed.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 23 Nov 2011 06:08:32 +0000 (07:08 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 23 Nov 2011 06:08:43 +0000 (07:08 +0100)
src/main/java/net/pterodactylus/sone/web/WebInterface.java

index 5ba3be7..4dc048c 100644 (file)
@@ -872,6 +872,7 @@ public class WebInterface implements CoreListener {
        public void postRemoved(Post post) {
                newPostNotification.remove(post);
                localPostNotification.remove(post);
+               mentionNotification.remove(post);
        }
 
        /**
@@ -881,6 +882,15 @@ public class WebInterface implements CoreListener {
        public void replyRemoved(PostReply reply) {
                newReplyNotification.remove(reply);
                localReplyNotification.remove(reply);
+               if (!getMentionedSones(reply.getText()).isEmpty()) {
+                       boolean isMentioned = false;
+                       for (PostReply existingReply : getCore().getReplies(reply.getPost())) {
+                               isMentioned |= getCore().isNewReply(reply.getId()) && !getMentionedSones(existingReply.getText()).isEmpty();
+                       }
+                       if (!isMentioned) {
+                               mentionNotification.remove(reply.getPost());
+                       }
+               }
        }
 
        /**