}
}
+ private boolean localSoneMentionedInNewPostOrReply(Post post) {
+ if (!post.getSone().isLocal()) {
+ if (!getMentionedSones(post.getText()).isEmpty() && !post.isKnown()) {
+ return true;
+ }
+ }
+ for (PostReply postReply : getCore().getReplies(post.getId())) {
+ if (postReply.getSone().isLocal()) {
+ continue;
+ }
+ if (!getMentionedSones(postReply.getText()).isEmpty() && !postReply.isKnown()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
//
// EVENT HANDLERS
//
}
if (!hasFirstStartNotification()) {
notificationManager.addNotification(isLocal ? localReplyNotification : newReplyNotification);
- if (!getMentionedSones(reply.getText()).isEmpty() && !isLocal && reply.getPost().isPresent() && (reply.getTime() <= System.currentTimeMillis())) {
+ if (reply.getPost().isPresent() && localSoneMentionedInNewPostOrReply(reply.getPost().get())) {
mentionNotification.add(reply.getPost().get());
notificationManager.addNotification(mentionNotification);
}
public void markPostKnown(MarkPostKnownEvent markPostKnownEvent) {
newPostNotification.remove(markPostKnownEvent.post());
localPostNotification.remove(markPostKnownEvent.post());
- mentionNotification.remove(markPostKnownEvent.post());
+ if (!localSoneMentionedInNewPostOrReply(markPostKnownEvent.post())) {
+ mentionNotification.remove(markPostKnownEvent.post());
+ }
}
/**
*/
@Subscribe
public void markReplyKnown(MarkPostReplyKnownEvent markPostReplyKnownEvent) {
- newReplyNotification.remove(markPostReplyKnownEvent.postReply());
- localReplyNotification.remove(markPostReplyKnownEvent.postReply());
- mentionNotification.remove(markPostReplyKnownEvent.postReply().getPost().get());
+ PostReply postReply = markPostReplyKnownEvent.postReply();
+ newReplyNotification.remove(postReply);
+ localReplyNotification.remove(postReply);
+ if (postReply.getPost().isPresent() && !localSoneMentionedInNewPostOrReply(postReply.getPost().get())) {
+ mentionNotification.remove(postReply.getPost().get());
+ }
}
/**
public void postRemoved(PostRemovedEvent postRemovedEvent) {
newPostNotification.remove(postRemovedEvent.post());
localPostNotification.remove(postRemovedEvent.post());
- mentionNotification.remove(postRemovedEvent.post());
+ if (!localSoneMentionedInNewPostOrReply(postRemovedEvent.post())) {
+ mentionNotification.remove(postRemovedEvent.post());
+ }
}
/**
PostReply reply = postReplyRemovedEvent.postReply();
newReplyNotification.remove(reply);
localReplyNotification.remove(reply);
- if (!getMentionedSones(reply.getText()).isEmpty() && reply.getPost().isPresent()) {
- boolean isMentioned = false;
- for (PostReply existingReply : getCore().getReplies(reply.getPostId())) {
- isMentioned |= !reply.isKnown() && !getMentionedSones(existingReply.getText()).isEmpty();
- }
- if (!isMentioned) {
- mentionNotification.remove(reply.getPost().get());
- }
+ if (reply.getPost().isPresent() && !localSoneMentionedInNewPostOrReply(reply.getPost().get())) {
+ mentionNotification.remove(reply.getPost().get());
}
}