From c731d14a20122ba8c02db2381305e821ad367712 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 13 Jan 2011 15:58:58 +0100 Subject: [PATCH] =?utf8?q?Return=20time=20of=20a=20post,=20and=20don?= =?utf8?q?=E2=80=99t=20load=20it=20if=20it=E2=80=99s=20older=20than=20the?= =?utf8?q?=20last=20post=20on=20the=20page.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../java/net/pterodactylus/sone/web/ajax/GetStatusAjaxPage.java | 1 + src/main/resources/static/javascript/sone.js | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/GetStatusAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/GetStatusAjaxPage.java index 172f237..a358fb1 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/GetStatusAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/GetStatusAjaxPage.java @@ -95,6 +95,7 @@ public class GetStatusAjaxPage extends JsonPage { jsonPost.put("id", post.getId()); jsonPost.put("sone", post.getSone().getId()); jsonPost.put("recipient", (post.getRecipient() != null) ? post.getRecipient().getId() : null); + jsonPost.put("time", post.getTime()); jsonPosts.add(jsonPost); } /* load new replies. */ diff --git a/src/main/resources/static/javascript/sone.js b/src/main/resources/static/javascript/sone.js index a3e79cd..cd34ed2 100644 --- a/src/main/resources/static/javascript/sone.js +++ b/src/main/resources/static/javascript/sone.js @@ -585,7 +585,7 @@ function getStatus() { }); /* process new posts. */ $.each(data.newPosts, function(index, value) { - loadNewPost(value.id, value.sone, value.recipient); + loadNewPost(value.id, value.sone, value.recipient, value.time); }); /* process new replies. */ $.each(data.newReplies, function(index, value) { @@ -706,7 +706,7 @@ function hasReply(replyId) { return $("#sone .reply#" + replyId).length > 0; } -function loadNewPost(postId, soneId, recipientId) { +function loadNewPost(postId, soneId, recipientId, time) { if (hasPost(postId)) { return; } @@ -716,6 +716,9 @@ function loadNewPost(postId, soneId, recipientId) { return; } } + if (getPostTime($("#sone .post").last()) > time) { + return; + } } $.getJSON("getPost.ajax", { "post" : postId }, function(data, textStatus) { if ((data != null) && data.success) { -- 2.7.4