     (.setAttribute element "title" new-title)))
 
 (defn- update-icons! [[from & new]]
-  (when from
-    (when new
-      (update-icon! from "gitique-first" "Last reviewed commit"))
+  (when (and from new)
+    (update-icon! from "gitique-first" "Last reviewed commit")
     (doseq [new-commit new]
       (update-icon! new-commit "gitique-enabled" "New commit")))
   (doseq [disabled-commit (js/document.querySelectorAll ".gitique-icon:not(.gitique-enabled):not(.gitique-first)")]

(defn- is? [type] (fn [item] (= (:type item) type)))
(defn- child-text [parent selector] (.-textContent (.querySelector parent selector)))

(defn- set-text! [selector text]
  (set! (.-textContent (js/document.querySelector selector)) text))

(defn- commit-sha [element]
  (last (string/split (.getAttribute (.querySelector element ".commit-id") "href") "/")))

(defn- commit-shas [item]
  (if-let [element (:element item)]
    (map commit-sha (.querySelectorAll (:element item) ".commit"))
    []))

(defn- item-type [creator item]
  (let [classes (.-classList item)]
    (cond (.contains classes "discussion-commits") "commit-block"
          (.contains classes "discussion-item-assigned") "assigned"

        current-pr (when (= (get components 3) "pull") {:repo repo :pr pr})]
    (swap! state assoc :current-pr current-pr)))

(defn ^:export watch
  "Run `main` once, then watch for DOM mutations in the PJAX container and run `main` when
  it changes"
  []
  (let [is-valid-mutation? #(and (= (.-type %) "childList") (not-empty (.-addedNodes %)))
        observer (js/MutationObserver. #(when (some is-valid-mutation? %) (main)))]
    (.observe observer pjax-wrapper #js{:childList true :attributes false :characterData false})
