 
 (reg-event-fx
  :redirect-to-page
+ [interceptors]
  (fn [_ [_ page]]
    {:pushy-replace-token! page}))
 
 (reg-event-fx
  :save-goal
+ [interceptors]
  (fn [{:keys [db]} [_ goal]]
    (let [[errs? params](schemas/validate goal schemas/+goal-schema+)]
-     (js/console.log errs? params)
      (if-not errs?
        {:db         db
         :http-xhrio (authenticated-xhrio {:method          (if (:id goal) :put :post)


(reg-event-db
 :user-me-failure
 (fn [{:keys [db]} _]
   ;; TODO
   db))

(reg-event-db
 :good-pings-result
 (fn [db [_ result]]
   (assoc db :pings result)))

(reg-event-db
 :bad-pings-result
 (fn [db [_ result]]
   (timbre/errorf "BAD RESULT: %s" (pr-str (keys result)))))

(reg-event-db
 :update-ping-query
 (fn [db [_ v]]
   (if (seq v)
     (assoc db :ping-query v)


(reg-event-fx
 :login/successful
 [interceptors]
 (fn [{:keys [db]} [_ result]]
   {:db             (-> db
                        (assoc :auth-token (:token result))
                        (dissoc :signup))
    :dispatch-n [[:fetch-pings] [:fetch-user-info]]
    :pushy-navigate :dashboard
    :set-cookie     {:auth-token (:token result)}}))

(reg-event-db
 :login/failed
 [interceptors]
 (fn [db [_ result]]
   ; TODO add handling of failure here
   db))
