/** All posts. */
private Map<String, Post> posts = new HashMap<String, Post>();
- /** All new posts. */
- private Set<String> newPosts = new HashSet<String>();
-
/** All known posts. */
- /* synchronize access on {@link #newPosts}. */
private Set<String> knownPosts = new HashSet<String>();
/** All replies. */
}
/**
- * Returns whether the given post ID is new.
- *
- * @param postId
- * The post ID
- * @return {@code true} if the post is considered to be new, {@code false}
- * otherwise
- */
- public boolean isNewPost(String postId) {
- synchronized (newPosts) {
- return !knownPosts.contains(postId) && newPosts.contains(postId);
- }
- }
-
- /**
* Returns all posts that have the given Sone as recipient.
*
* @see Post#getRecipient()
}
}
List<Post> storedPosts = storedSone.getPosts();
- synchronized (newPosts) {
+ synchronized (knownPosts) {
for (Post post : sone.getPosts()) {
post.setSone(storedSone);
if (!storedPosts.contains(post)) {
if (post.getTime() < getSoneFollowingTime(sone)) {
+ sone.setKnown(true);
knownPosts.add(post.getId());
} else if (!knownPosts.contains(post.getId())) {
- newPosts.add(post.getId());
coreListenerManager.fireNewPostFound(post);
+ } else {
+ sone.setKnown(true);
}
}
posts.put(post.getId(), post);
knownSones.add(friend);
}
}
- synchronized (newPosts) {
+ synchronized (knownPosts) {
for (Post post : posts) {
knownPosts.add(post.getId());
}
synchronized (posts) {
posts.put(post.getId(), post);
}
- synchronized (newPosts) {
- newPosts.add(post.getId());
- coreListenerManager.fireNewPostFound(post);
- }
+ coreListenerManager.fireNewPostFound(post);
sone.addPost(post);
touchConfiguration();
localElementTicker.registerEvent(System.currentTimeMillis() + 10 * 1000, new Runnable() {
posts.remove(post.getId());
}
coreListenerManager.firePostRemoved(post);
- synchronized (newPosts) {
- markPostKnown(post);
- knownPosts.remove(post.getId());
- }
+ markPostKnown(post);
touchConfiguration();
}
* The post to mark as known
*/
public void markPostKnown(Post post) {
- synchronized (newPosts) {
- newPosts.remove(post.getId());
+ post.setKnown(true);
+ synchronized (knownPosts) {
if (knownPosts.add(post.getId())) {
coreListenerManager.fireMarkPostKnown(post);
touchConfiguration();
/* save known posts. */
int postCounter = 0;
- synchronized (newPosts) {
+ synchronized (knownPosts) {
for (String knownPostId : knownPosts) {
configuration.getStringValue("KnownPosts/" + postCounter++ + "/ID").setValue(knownPostId);
}
if (knownPostId == null) {
break;
}
- synchronized (newPosts) {
+ synchronized (knownPosts) {
knownPosts.add(knownPostId);
}
}
return;
}
synchronized (posts) {
- synchronized (newPosts) {
+ synchronized (knownPosts) {
for (Post post : sone.getPosts()) {
posts.remove(post.getId());
- newPosts.remove(post.getId());
coreListenerManager.firePostRemoved(post);
}
}
*
* @param insertionDelay
* The insertion delay to validate
- * @return {@code true} if the given insertion delay was valid, {@code
- * false} otherwise
+ * @return {@code true} if the given insertion delay was valid,
+ * {@code false} otherwise
*/
public boolean validateInsertionDelay(Integer insertionDelay) {
return options.getIntegerOption("InsertionDelay").validate(insertionDelay);