From: David ‘Bombe’ Roden Date: Thu, 30 Dec 2010 21:25:23 +0000 (+0100) Subject: Merge branch 'release-0.3.6' X-Git-Tag: 0.3.6^0 X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=commitdiff_plain;h=2001770a82d5da588b466ecacde4c6fcf4c83ea5;hp=a99d9c153277863d3ce9d3d524b118a1898d27a5 Merge branch 'release-0.3.6' --- diff --git a/pom.xml b/pom.xml index 0eda605..640c1e4 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 net.pterodactylus sone - 0.3.5-1 + 0.3.6 net.pterodactylus @@ -18,7 +18,7 @@ org.freenetproject fred - 0.7.5.1305 + 0.7.5.1311 provided diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index 2ef2d57..1a92901 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -86,6 +86,9 @@ public class Core implements IdentityListener { /** The configuration. */ private Configuration configuration; + /** Whether we’re currently saving the configuration. */ + private boolean storingConfiguration = false; + /** The identity manager. */ private final IdentityManager identityManager; @@ -1306,6 +1309,7 @@ public class Core implements IdentityListener { if (newPosts.remove(post.getId())) { knownPosts.add(post.getId()); coreListenerManager.fireMarkPostKnown(post); + saveConfiguration(); } } } @@ -1386,6 +1390,7 @@ public class Core implements IdentityListener { if (newReplies.remove(reply.getId())) { knownReplies.add(reply.getId()); coreListenerManager.fireMarkReplyKnown(reply); + saveConfiguration(); } } } @@ -1406,6 +1411,7 @@ public class Core implements IdentityListener { soneInserter.stop(); } } + soneDownloader.stop(); saveConfiguration(); stopped = true; } @@ -1413,7 +1419,15 @@ public class Core implements IdentityListener { /** * Saves the current options. */ - public synchronized void saveConfiguration() { + public void saveConfiguration() { + synchronized (configuration) { + if (storingConfiguration) { + logger.log(Level.FINE, "Already storing configuration…"); + return; + } + storingConfiguration = true; + } + /* store the options first. */ try { configuration.getIntValue("Option/InsertionDelay").setValue(options.getIntegerOption("InsertionDelay").getReal()); @@ -1453,6 +1467,10 @@ public class Core implements IdentityListener { } catch (ConfigurationException ce1) { logger.log(Level.SEVERE, "Could not store configuration!", ce1); + } finally { + synchronized (configuration) { + storingConfiguration = false; + } } } diff --git a/src/main/java/net/pterodactylus/sone/core/FreenetInterface.java b/src/main/java/net/pterodactylus/sone/core/FreenetInterface.java index f5d7b66..6737d63 100644 --- a/src/main/java/net/pterodactylus/sone/core/FreenetInterface.java +++ b/src/main/java/net/pterodactylus/sone/core/FreenetInterface.java @@ -65,12 +65,10 @@ public class FreenetInterface { * * @param node * The node to interact with - * @param client - * The high-level client */ - public FreenetInterface(Node node, HighLevelSimpleClient client) { + public FreenetInterface(Node node) { this.node = node; - this.client = client; + this.client = node.clientCore.makeClient(RequestStarter.INTERACTIVE_PRIORITY_CLASS, false, true); } // diff --git a/src/main/java/net/pterodactylus/sone/main/SonePlugin.java b/src/main/java/net/pterodactylus/sone/main/SonePlugin.java index 2980b68..e5b6482 100644 --- a/src/main/java/net/pterodactylus/sone/main/SonePlugin.java +++ b/src/main/java/net/pterodactylus/sone/main/SonePlugin.java @@ -78,7 +78,7 @@ public class SonePlugin implements FredPlugin, FredPluginL10n, FredPluginBaseL10 } /** The version. */ - public static final Version VERSION = new Version(0, 3, 5, 1); + public static final Version VERSION = new Version(0, 3, 6); /** The logger. */ private static final Logger logger = Logging.getLogger(SonePlugin.class); @@ -167,7 +167,7 @@ public class SonePlugin implements FredPlugin, FredPluginL10n, FredPluginBaseL10 } /* create freenet interface. */ - FreenetInterface freenetInterface = new FreenetInterface(pluginRespirator.getNode(), pluginRespirator.getHLSimpleClient()); + FreenetInterface freenetInterface = new FreenetInterface(pluginRespirator.getNode()); /* create web of trust connector. */ PluginConnector pluginConnector = new PluginConnector(pluginRespirator); diff --git a/src/main/java/net/pterodactylus/sone/web/IndexPage.java b/src/main/java/net/pterodactylus/sone/web/IndexPage.java index 7562526..a33072f 100644 --- a/src/main/java/net/pterodactylus/sone/web/IndexPage.java +++ b/src/main/java/net/pterodactylus/sone/web/IndexPage.java @@ -54,15 +54,22 @@ public class IndexPage extends SoneTemplatePage { @Override protected void processTemplate(Request request, Template template) throws RedirectException { super.processTemplate(request, template); - Sone sone = getCurrentSone(request.getToadletContext()); + Sone currentSone = getCurrentSone(request.getToadletContext()); List allPosts = new ArrayList(); - allPosts.addAll(sone.getPosts()); - for (String friendSoneId : sone.getFriends()) { + allPosts.addAll(currentSone.getPosts()); + for (String friendSoneId : currentSone.getFriends()) { if (!webInterface.getCore().hasSone(friendSoneId)) { continue; } allPosts.addAll(webInterface.getCore().getSone(friendSoneId).getPosts()); } + for (Sone sone : webInterface.getCore().getSones()) { + for (Post post : sone.getPosts()) { + if (currentSone.equals(post.getRecipient()) && !allPosts.contains(post)) { + allPosts.add(post); + } + } + } Collections.sort(allPosts, Post.TIME_COMPARATOR); template.set("posts", allPosts); } diff --git a/src/main/resources/static/javascript/sone.js b/src/main/resources/static/javascript/sone.js index acb1d46..77d401a 100644 --- a/src/main/resources/static/javascript/sone.js +++ b/src/main/resources/static/javascript/sone.js @@ -672,19 +672,39 @@ function isKnownSonesPage() { return getPageId() == "known-sones"; } -var loadedPosts = {}; -var loadedReplies = {}; +/** + * Returns whether a post with the given ID exists on the current page. + * + * @param postId + * The post ID to check for + * @returns {Boolean} true if a post with the given ID already + * exists on the page, false otherwise + */ +function hasPost(postId) { + return $(".post#" + postId).length > 0; +} + +/** + * Returns whether a reply with the given ID exists on the current page. + * + * @param replyId + * The reply ID to check for + * @returns {Boolean} true if a reply with the given ID already + * exists on the page, false otherwise + */ +function hasReply(replyId) { + return $("#sone .reply#" + replyId).length > 0; +} function loadNewPost(postId) { - if (postId in loadedPosts) { + if (hasPost(postId)) { return; } $.getJSON("getPost.ajax", { "post" : postId }, function(data, textStatus) { if ((data != null) && data.success) { - if (data.post.id in loadedPosts) { + if (hasPost(data.post.id)) { return; } - loadedPosts[data.post.id] = true; if (!isIndexPage() && !(isViewSonePage() && ((getShownSoneId() == data.post.sone) || (getShownSoneId() == data.post.recipient)))) { return; } @@ -709,16 +729,15 @@ function loadNewPost(postId) { } function loadNewReply(replyId) { - if (replyId in loadedReplies) { + if (hasReply(replyId)) { return; } $.getJSON("getReply.ajax", { "reply": replyId }, function(data, textStatus) { /* find post. */ if ((data != null) && data.success) { - if (data.reply.id in loadedReplies) { + if (hasReply(data.reply.id)) { return; } - loadedReplies[data.reply.id] = true; $("#sone .post#" + data.reply.postId).each(function() { var firstNewerReply = null; $(this).find(".replies .reply").each(function() { @@ -823,6 +842,9 @@ $(document).ready(function() { getTranslation("WebInterface.DefaultText.StatusUpdate", function(defaultText) { registerInputTextareaSwap("#sone #update-status .status-input", defaultText, "text", false, false); $("#sone #update-status").submit(function() { + if ($(this).find(":input").hasClass("default")) { + return false; + } text = $(this).find(":input:enabled").val(); $.getJSON("createPost.ajax", { "formPassword": getFormPassword(), "text": text }, function(data, textStatus) { if ((data != null) && data.success) {