 (declare add-icons! maybe-show-new update-icons! update-dom!)
 
 (add-watch state :pr-change (fn [_ _ old new]
-                              (let [new-pr (:current-pr new)]
-                                (when (not= (:current-pr old) new-pr)
+                              (let [new-pr (:current-pr new)
+                                    new-count (:commit-count new)]
+                                (when (or (not= (:current-pr old) new-pr)
+                                          (and (pos? new-count) (not= (:commit-count old) new-count)))
                                   (add-icons!)
                                   (maybe-show-new (:repo new-pr) (:pr new-pr))))))
 

(enable-console-print!)

(def state (atom {:current-pr {} ;; {:repo "smcgivern/gitique" :pr "1"}
                  :base-commit nil ;; the start point for the diff
                  :all-commits '() ;; all of the commits found on the page
                  :files '() ;; the files property of the GitHub API response

  (when pjax-wrapper
    (let [is-valid-mutation? #(and (= (.-type %) "childList") (seq (.-addedNodes %)))
          observer (js/MutationObserver. #(when (some is-valid-mutation? %) (main)))]
      (.observe observer pjax-wrapper #js{:childList true :attributes false :characterData false :subtree true})))
  (main))
