projects
/
Sone.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add filter and sort options to “known Sones” page.
[Sone.git]
/
src
/
main
/
java
/
net
/
pterodactylus
/
sone
/
web
/
WebInterface.java
diff --git
a/src/main/java/net/pterodactylus/sone/web/WebInterface.java
b/src/main/java/net/pterodactylus/sone/web/WebInterface.java
index
c9547fb
..
73436c7
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/web/WebInterface.java
+++ b/
src/main/java/net/pterodactylus/sone/web/WebInterface.java
@@
-100,6
+100,7
@@
import net.pterodactylus.util.cache.CacheItem;
import net.pterodactylus.util.cache.DefaultCacheItem;
import net.pterodactylus.util.cache.MemoryCache;
import net.pterodactylus.util.cache.ValueRetriever;
import net.pterodactylus.util.cache.DefaultCacheItem;
import net.pterodactylus.util.cache.MemoryCache;
import net.pterodactylus.util.cache.ValueRetriever;
+import net.pterodactylus.util.collection.SetBuilder;
import net.pterodactylus.util.filter.Filters;
import net.pterodactylus.util.logging.Logging;
import net.pterodactylus.util.notify.Notification;
import net.pterodactylus.util.filter.Filters;
import net.pterodactylus.util.logging.Logging;
import net.pterodactylus.util.notify.Notification;
@@
-168,6
+169,12
@@
public class WebInterface implements CoreListener {
/** The “new reply” notification. */
private final ListNotification<Reply> newReplyNotification;
/** The “new reply” notification. */
private final ListNotification<Reply> newReplyNotification;
+ /** The invisible “local post” notification. */
+ private final ListNotification<Post> localPostNotification;
+
+ /** The invisible “local reply” notification. */
+ private final ListNotification<Reply> localReplyNotification;
+
/** The “you have been mentioned” notification. */
private final ListNotification<Post> mentionNotification;
/** The “you have been mentioned” notification. */
private final ListNotification<Post> mentionNotification;
@@
-236,9
+243,15
@@
public class WebInterface implements CoreListener {
Template newPostNotificationTemplate = TemplateParser.parse(createReader("/templates/notify/newPostNotification.html"));
newPostNotification = new ListNotification<Post>("new-post-notification", "posts", newPostNotificationTemplate, false);
Template newPostNotificationTemplate = TemplateParser.parse(createReader("/templates/notify/newPostNotification.html"));
newPostNotification = new ListNotification<Post>("new-post-notification", "posts", newPostNotificationTemplate, false);
+ Template localPostNotificationTemplate = TemplateParser.parse(createReader("/templates/notify/newPostNotification.html"));
+ localPostNotification = new ListNotification<Post>("local-post-notification", "posts", localPostNotificationTemplate, false);
+
Template newReplyNotificationTemplate = TemplateParser.parse(createReader("/templates/notify/newReplyNotification.html"));
newReplyNotification = new ListNotification<Reply>("new-reply-notification", "replies", newReplyNotificationTemplate, false);
Template newReplyNotificationTemplate = TemplateParser.parse(createReader("/templates/notify/newReplyNotification.html"));
newReplyNotification = new ListNotification<Reply>("new-reply-notification", "replies", newReplyNotificationTemplate, false);
+ Template localReplyNotificationTemplate = TemplateParser.parse(createReader("/templates/notify/newReplyNotification.html"));
+ localReplyNotification = new ListNotification<Reply>("local-reply-notification", "replies", localReplyNotificationTemplate, false);
+
Template mentionNotificationTemplate = TemplateParser.parse(createReader("/templates/notify/mentionNotification.html"));
mentionNotification = new ListNotification<Post>("mention-notification", "posts", mentionNotificationTemplate, false);
Template mentionNotificationTemplate = TemplateParser.parse(createReader("/templates/notify/mentionNotification.html"));
mentionNotification = new ListNotification<Post>("mention-notification", "posts", mentionNotificationTemplate, false);
@@
-420,7
+433,7
@@
public class WebInterface implements CoreListener {
* @return The new posts
*/
public Set<Post> getNewPosts() {
* @return The new posts
*/
public Set<Post> getNewPosts() {
- return new
HashSet<Post>(newPostNotification.getElements()
);
+ return new
SetBuilder<Post>().addAll(newPostNotification.getElements()).addAll(localPostNotification.getElements()).get(
);
}
/**
}
/**
@@
-430,7
+443,7
@@
public class WebInterface implements CoreListener {
* @return The new replies
*/
public Set<Reply> getNewReplies() {
* @return The new replies
*/
public Set<Reply> getNewReplies() {
- return new
HashSet<Reply>(newReplyNotification.getElements()
);
+ return new
SetBuilder<Reply>().addAll(newReplyNotification.getElements()).addAll(localReplyNotification.getElements()).get(
);
}
/**
}
/**
@@
-731,10
+744,15
@@
public class WebInterface implements CoreListener {
*/
@Override
public void newPostFound(Post post) {
*/
@Override
public void newPostFound(Post post) {
- newPostNotification.add(post);
+ boolean isLocal = getCore().isLocalSone(post.getSone());
+ if (isLocal) {
+ localPostNotification.add(post);
+ } else {
+ newPostNotification.add(post);
+ }
if (!hasFirstStartNotification()) {
if (!hasFirstStartNotification()) {
- notificationManager.addNotification(newPostNotification);
- if (!getMentionedSones(post.getText()).isEmpty()) {
+ notificationManager.addNotification(
isLocal ? localPostNotification :
newPostNotification);
+ if (!getMentionedSones(post.getText()).isEmpty()
&& !isLocal
) {
mentionNotification.add(post);
notificationManager.addNotification(mentionNotification);
}
mentionNotification.add(post);
notificationManager.addNotification(mentionNotification);
}
@@
-751,10
+769,15
@@
public class WebInterface implements CoreListener {
if (reply.getPost().getSone() == null) {
return;
}
if (reply.getPost().getSone() == null) {
return;
}
- newReplyNotification.add(reply);
+ boolean isLocal = getCore().isLocalSone(reply.getSone());
+ if (isLocal) {
+ localReplyNotification.add(reply);
+ } else {
+ newReplyNotification.add(reply);
+ }
if (!hasFirstStartNotification()) {
if (!hasFirstStartNotification()) {
- notificationManager.addNotification(newReplyNotification);
- if (!getMentionedSones(reply.getText()).isEmpty()) {
+ notificationManager.addNotification(
isLocal ? localReplyNotification :
newReplyNotification);
+ if (!getMentionedSones(reply.getText()).isEmpty()
&& !isLocal
) {
mentionNotification.add(reply.getPost());
notificationManager.addNotification(mentionNotification);
}
mentionNotification.add(reply.getPost());
notificationManager.addNotification(mentionNotification);
}
@@
-777,6
+800,7
@@
public class WebInterface implements CoreListener {
@Override
public void markPostKnown(Post post) {
newPostNotification.remove(post);
@Override
public void markPostKnown(Post post) {
newPostNotification.remove(post);
+ localPostNotification.remove(post);
mentionNotification.remove(post);
}
mentionNotification.remove(post);
}
@@
-786,6
+810,7
@@
public class WebInterface implements CoreListener {
@Override
public void markReplyKnown(Reply reply) {
newReplyNotification.remove(reply);
@Override
public void markReplyKnown(Reply reply) {
newReplyNotification.remove(reply);
+ localReplyNotification.remove(reply);
mentionNotification.remove(reply.getPost());
}
mentionNotification.remove(reply.getPost());
}
@@
-803,6
+828,7
@@
public class WebInterface implements CoreListener {
@Override
public void postRemoved(Post post) {
newPostNotification.remove(post);
@Override
public void postRemoved(Post post) {
newPostNotification.remove(post);
+ localPostNotification.remove(post);
}
/**
}
/**
@@
-811,6
+837,7
@@
public class WebInterface implements CoreListener {
@Override
public void replyRemoved(Reply reply) {
newReplyNotification.remove(reply);
@Override
public void replyRemoved(Reply reply) {
newReplyNotification.remove(reply);
+ localReplyNotification.remove(reply);
}
/**
}
/**