From f8be9e71032b0c279ad8170e8b5ad10c88fe31d2 Mon Sep 17 00:00:00 2001 From: Fang Lu Date: Mon, 30 Oct 2017 18:06:28 -0500 Subject: [PATCH] Fix update message Don't show update message for first-time loading --- node_modules/catalog.js | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/node_modules/catalog.js b/node_modules/catalog.js index abe440b..a859e0f 100644 --- a/node_modules/catalog.js +++ b/node_modules/catalog.js @@ -77,17 +77,19 @@ Catalog.prototype.update = function(code) { } var newcrns = []; - for (var type in course.sections) { - course.sections[type].forEach((section) => { - var idx = oldcrns.indexOf(section.crn); - if (idx == -1) { - newcrns.push(section.crn); - } else { - oldcrns.splice(idx, 1); - } - this.sections[section.crn] = section; - section.course = course; - }); + if (oldcrns.length != 0) { + for (var type in course.sections) { + course.sections[type].forEach((section) => { + var idx = oldcrns.indexOf(section.crn); + if (idx == -1) { + newcrns.push(section.crn); + } else { + oldcrns.splice(idx, 1); + } + this.sections[section.crn] = section; + section.course = course; + }); + } } resolve({course: course, added: newcrns, removed: oldcrns}); }).bind(this), (err) => {