From 1ed577bcb4b6650e89659485e69e6ffc29bcf7fd Mon Sep 17 00:00:00 2001 From: Nicolai Tellefsen Date: Tue, 22 Mar 2016 16:23:23 +0100 Subject: NMS: Fix bug in comment refresh logic --- web/nms.gathering.org/js/nms-info-box.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'web/nms.gathering.org/js/nms-info-box.js') diff --git a/web/nms.gathering.org/js/nms-info-box.js b/web/nms.gathering.org/js/nms-info-box.js index 11dbb93..2d12d56 100644 --- a/web/nms.gathering.org/js/nms-info-box.js +++ b/web/nms.gathering.org/js/nms-info-box.js @@ -201,12 +201,10 @@ nmsInfoBox._windowTypes.switchInfo = { }, update: function(type) { - console.log("Updating switch info: " + type); switch (type) { case 'comments': if(this.activeView == "comments" && this.commentsHash != nmsData.comments.hash) { nmsInfoBox._windowTypes.switchInfo.showComments(); - console.log("change"); } break; } @@ -232,19 +230,15 @@ nmsInfoBox._windowTypes.switchInfo = { commentbox.innerHTML = '
'; // If we have no switch data, so just show comment form - if(!nmsData.comments || !nmsData.comments.comments || !nmsData.comments.comments[this.sw]) { + if(!nmsData.comments || !nmsData.comments.comments) { this.commentsHash = false; - domObj.appendChild(commentbox); - this.childContent = domObj; - nmsInfoBox.refresh(); - return; // We have data, but its old, so don't change data - } else if(this.commentsHash == nmsData.comments.hash) { + } else if(this.commentsHash != false && this.commentsHash == nmsData.comments.hash) { return; - // We have new data, refresh - } else { + // We have data, refresh + } else if(nmsData.comments.comments[this.sw]) { this.commentsHash = nmsData.comments.hash; for (var c in nmsData.comments.comments[this.sw]["comments"]) { var comment = nmsData.comments.comments[this.sw]["comments"][c]; @@ -259,6 +253,10 @@ nmsInfoBox._windowTypes.switchInfo = { domObj.appendChild(commenttable); $(function () { $('[data-toggle="popover"]').popover({placement:"top",continer:'body'}) }) } + + // We have no data for this switch, but its still correct + } else { + this.commentsHash = nmsData.comments.hash; } domObj.appendChild(commentbox); @@ -337,6 +335,7 @@ nmsInfoBox._windowTypes.switchInfo = { }, unload: function() { this.childContent = false; + this.commentsHash = false; this.activeView = ""; }, save: function() { -- cgit v1.2.3