Only process new posts and replies if the notifications changed.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 29 May 2012 06:55:04 +0000 (08:55 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 29 May 2012 06:55:04 +0000 (08:55 +0200)
src/main/java/net/pterodactylus/sone/web/ajax/GetStatusAjaxPage.java
src/main/resources/static/javascript/sone.js

index 28fee14..223a79f 100644 (file)
@@ -91,6 +91,7 @@ public class GetStatusAjaxPage extends JsonPage {
                }
                /* load notifications. */
                List<Notification> notifications = ListNotificationFilters.filterNotifications(webInterface.getNotifications().getNotifications(), currentSone);
                }
                /* load notifications. */
                List<Notification> notifications = ListNotificationFilters.filterNotifications(webInterface.getNotifications().getNotifications(), currentSone);
+               Collections.sort(notifications, Notification.CREATED_TIME_SORTER);
                int notificationHash = HashCode.hashCode(notifications);
                /* load new posts. */
                Set<Post> newPosts = webInterface.getNewPosts();
                int notificationHash = HashCode.hashCode(notifications);
                /* load new posts. */
                Set<Post> newPosts = webInterface.getNewPosts();
index 414dd02..6077049 100644 (file)
@@ -1206,15 +1206,15 @@ function getStatus() {
                        if (data.notificationHash != getNotificationHash()) {
                                console.log("Old hash: ", getNotificationHash(), ", new hash: ", data.notificationHash);
                                requestNotifications();
                        if (data.notificationHash != getNotificationHash()) {
                                console.log("Old hash: ", getNotificationHash(), ", new hash: ", data.notificationHash);
                                requestNotifications();
+                               /* process new posts. */
+                               $.each(data.newPosts, function(index, value) {
+                                       loadNewPost(value.id, value.sone, value.recipient, value.time);
+                               });
+                               /* process new replies. */
+                               $.each(data.newReplies, function(index, value) {
+                                       loadNewReply(value.id, value.sone, value.post, value.postSone);
+                               });
                        }
                        }
-                       /* process new posts. */
-                       $.each(data.newPosts, function(index, value) {
-                               loadNewPost(value.id, value.sone, value.recipient, value.time);
-                       });
-                       /* process new replies. */
-                       $.each(data.newReplies, function(index, value) {
-                               loadNewReply(value.id, value.sone, value.post, value.postSone);
-                       });
                        /* do it again in 5 seconds. */
                        setTimeout(getStatus, 5000);
                } else {
                        /* do it again in 5 seconds. */
                        setTimeout(getStatus, 5000);
                } else {