Dump notification hash to console.
[Sone.git] / src / main / resources / static / javascript / sone.js
index a3dbc64..78d68f1 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
@@ -1182,6 +1200,10 @@ function getStatus() {
                        if (!notLoggedIn) {
                                showOfflineMarker(!online);
                        }
+                       if (data.notificationHash != getNotificationHash()) {
+                               console.log("Old hash: ", getNotificationHash(), ", new hash: ", data.notificationHash);
+                               setNotificationHash(data.notificationHash);
+                       }
                        /* search for removed notifications. */
                        $("#sone #notification-area .notification").each(function() {
                                notificationId = $(this).attr("id");