Add method to set the new notification hash.
[Sone.git] / src / main / resources / static / javascript / sone.js
index bbd039c..591afa0 100644 (file)
@@ -1088,6 +1088,24 @@ function ajaxifyNotification(notification) {
 }
 
 /**
+ * Returns the notification hash. This hash is used in {@link #getStatus()} to
+ * determine whether the notifications changed and need to be reloaded.
+ */
+public getNotificationHash() {
+       return $("#sone #notification-area #notification-hash").text();
+}
+
+/**
+ * Sets the notification hash.
+ *
+ * @param notificationHash
+ *            The new notification hash
+ */
+public setNotificationHash(notificationHash) {
+       $("#sone #notification-area #notification-hash").text(notificationHash);
+}
+
+/**
  * Retrieves element IDs from notification elements.
  *
  * @param notification
@@ -1193,17 +1211,17 @@ function getStatus() {
                                        }
                                });
                                if (!foundNotification) {
-                                       if (notificationId == "new-sone-notification") {
+                                       if (notificationId == "new-sone-notification" && (data.options["ShowNotification/NewSones"] == true)) {
                                                $(".new-sone-id", this).each(function(index, element) {
                                                        soneId = $(this).text();
                                                        markSoneAsKnown(getSone(soneId), true);
                                                });
-                                       } else if (notificationId == "new-post-notification") {
+                                       } else if (notificationId == "new-post-notification" && (data.options["ShowNotification/NewPosts"] == true)) {
                                                $(".post-id", this).each(function(index, element) {
                                                        postId = $(this).text();
                                                        markPostAsKnown(getPost(postId), true);
                                                });
-                                       } else if (notificationId == "new-reply-notification") {
+                                       } else if (notificationId == "new-reply-notification" && (data.options["ShowNotification/NewReplies"] == true)) {
                                                $(".reply-id", this).each(function(index, element) {
                                                        replyId = $(this).text();
                                                        markReplyAsKnown(getReply(replyId), true);
@@ -1347,7 +1365,7 @@ function isViewSonePage() {
  * @returns The ID of the currently shown Sone
  */
 function getShownSoneId() {
-       return $("#sone .sone-id").text();
+       return $("#sone .sone-id").first().text();
 }
 
 /**