             [salava.core.ui.helper :refer [path-for]]
             [salava.badge.ui.helper :as bh]))
 
+(defn update-state [state]
+  (ajax/GET
+    (path-for "/obpv1/badge" true)
+    {:handler (fn [data]
+                (swap! state assoc :badges (filter #(= "accepted" (:status %)) data)
+                                   :pending (filter #(= "pending" (:status %)) data)
+                                   :initializing false))}))
+
 (defn set-visibility [visibility state]
   (swap! state assoc-in [:badge-settings :visibility] visibility))
 
-(defn delete-badge [id]
+(defn delete-badge [id state]
   (ajax/DELETE
     (path-for (str "/obpv1/badge/" id))
     {:handler (fn []
-                (.reload js/window.location))}))
+                (update-state state))}))
 
 (defn save-settings [state]
   (let [{:keys [id visibility tags rating evidence-url]} (:badge-settings @state)]

           (t :badge/Cancel)]
          [:button {:type "button"
                    :class "btn btn-warning"
                    :on-click #(delete-badge id)}
           (t :badge/Delete)]]
         [:button {:type "button"
                   :class "btn btn-warning delete-button"

                 :rating       (if (pos? rating) rating nil)
                 :evidence-url evidence-url}
       :handler (fn []
                  (update-state state))})))

(defn settings-modal [{:keys [id name description image_file issued_on expires_on revoked issuer_content_url issuer_content_name issuer_contact issuer_image]} state]
  [:div {:id "badge-settings"}
