   ; - But you can create the card at the top
   ; - And then you can assemble them (group-by or filter)
   (let [filter (r/cursor app-state [:filter])
-        card-ids (filter-by-title @filter (:cards @app-state))
-        card-cursors (map #(r/cursor app-state [:cards %1]) card-ids)]
+        cards (reaction (filter-by-title @filter (:cards @app-state)))
+        card-ids (reaction (map first @cards))
+        card-cursors (map #(r/cursor app-state [:cards %]) @card-ids)]
     [:div
      ; TODO - Try to add a button to show details to all tickets
      (render-filter filter)

  ])

(defn render-tasks
  [{:keys [tasks] :as card}]
  (let [on-remove #(update-card! (api/remove-task-at card %))
        on-check #(update-card! (update-in card [:tasks % :done] not))]
    [:div.checklist
     [:ul
      (map
        (fn [idx t]
          ^{:key t} [render-task #(on-remove idx) #(on-check idx) t])
        (range) tasks)]
     ]))

(defn render-add-task
  "Render the text field allowing to add new tasks to a card"
  [card]
  [:input.checklist--add-task
   {:type "text"
    :placeholder "Type then hit Enter to add a task"
    :on-key-press
    (fn [e]
      (when (= "Enter" (.-key e))
        (update-card! (api/add-task card (.. e -target -value)))
        (set! (.. e -target -value) "")
      ))
   }])

  [status cards]
  (filter #(= status (-> % deref :status)) cards))

 (defn filter-by-title
   "Keep only cards that contains the searched string inside their title"
   [title cards]
   (if (empty? title)
     cards
     (filter #(utils/str-contains (-> % second :title) title) cards)))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

