Show posts mentioning a local Sone by a new notification.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 8 Jun 2011 14:00:32 +0000 (16:00 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 8 Jun 2011 14:00:32 +0000 (16:00 +0200)
This fixes #188.

src/main/resources/static/javascript/sone.js
src/main/resources/templates/include/viewPost.html
src/main/resources/templates/include/viewReply.html

index a489c60..0cc6480 100644 (file)
@@ -1235,6 +1235,14 @@ function loadNewPost(postId, soneId, recipientId, time) {
                                }
                        });
                        newPost = $(data.post.html).addClass("hidden");
+                       if ($(".post-author-local", newPost).text() == "true") {
+                               newPost.removeClass("new");
+                               (function(newPost) {
+                                       setTimeout(function() {
+                                               markPostAsKnown(newPost, false);
+                                       }, 5000);
+                               })(newPost);
+                       }
                        if (firstOlderPost != null) {
                                newPost.insertBefore(firstOlderPost);
                        }
@@ -1268,6 +1276,14 @@ function loadNewReply(replyId, soneId, postId, postSoneId) {
                                        }
                                });
                                newReply = $(data.reply.html).addClass("hidden");
+                               if ($(".reply-author-local", newReply).text() == "true") {
+                                       newReply.removeClass("new");
+                                       (function(newReply) {
+                                               setTimeout(function() {
+                                                       markReplyAsKnown(newReply, false);
+                                               }, 5000);
+                                       })(newReply);
+                               }
                                if (firstNewerReply != null) {
                                        newReply.insertBefore(firstNewerReply);
                                } else {
@@ -1308,7 +1324,7 @@ function markSoneAsKnown(soneElement, skipRequest) {
 function markPostAsKnown(postElements, skipRequest) {
        $(postElements).each(function() {
                postElement = this;
-               if ($(postElement).hasClass("new")) {
+               if ($(postElement).hasClass("new") || ((typeof skipRequest != "undefined") && !skipRequest)) {
                        (function(postElement) {
                                $(postElement).removeClass("new");
                                if ((typeof skipRequest == "undefined") || !skipRequest) {
@@ -1324,7 +1340,7 @@ function markPostAsKnown(postElements, skipRequest) {
 function markReplyAsKnown(replyElements, skipRequest) {
        $(replyElements).each(function() {
                replyElement = this;
-               if ($(replyElement).hasClass("new")) {
+               if ($(replyElement).hasClass("new") || ((typeof skipRequest != "undefined") && !skipRequest)) {
                        (function(replyElement) {
                                $(replyElement).removeClass("new");
                                if ((typeof skipRequest == "undefined") || !skipRequest) {
index 8b7ccb8..b451f2b 100644 (file)
@@ -2,6 +2,7 @@
        <a name="post-<% post.id|html>"></a>
        <div class="post-time hidden"><% post.time|html></div>
        <div class="post-author hidden"><% post.sone.id|html></div>
+       <div class="post-author-local hidden"><% post.sone.local></div>
        <div class="avatar">
                <%if post.loaded>
                        <img src="/WebOfTrust/GetIdenticon?identity=<% post.sone.id|html>&amp;width=48&height=48" width="48" height="48" alt="Avatar Image" />
index 2fa4885..2507917 100644 (file)
@@ -2,6 +2,7 @@
        <a name="reply-<% reply.id|html>"></a>
        <div class="reply-time hidden"><% reply.time|html></div>
        <div class="reply-author hidden"><% reply.sone.id|html></div>
+       <div class="reply-author-local hidden"><% reply.sone.local></div>
        <div class="avatar">
                <img src="/WebOfTrust/GetIdenticon?identity=<% reply.sone.id|html>&amp;width=36&height=36" width="36" height="36" alt="Avatar Image" />
        </div>