             [salava.core.i18n :refer [t]]
             [salava.core.helper :refer [dump]]
             [salava.social.ui.follow :as f]
-            [salava.core.time :refer [date-from-unix-time]]
-            
-            ))
+            [salava.core.time :refer [date-from-unix-time]]))
 
 (defn init-data [state]
   (ajax/GET
    (path-for (str "/obpv1/social/messages/" (:badge_content_id @state) "/" (:page_count @state)))
    {:handler (fn [data]
-               (swap! state assoc :messages (into (:messages @state) (:messages data))
-                                 :message ""
-                                 :page_count (inc (:page_count @state))
-                                 :messages_left (:messages_left data)))})
-  )
+               (swap! state assoc
+                      :messages (into (:messages @state) (:messages data))
+                      :message ""
+                      :page_count (inc (:page_count @state))
+                      :messages_left (:messages_left data)))}))
 
 
 (defn save-message [state]


(defn message-list-item [{:keys [message first_name last_name ctime id profile_picture user_id]} state]
  [:div {:class "media message-item" :key id}
  
   [:div.msgcontent
   [:span {:class "pull-left"}
    [:img {:class "message-profile-img" :src (profile-picture profile_picture)}]]
   [:div {:class "media-body"}
    [:h4 {:class "media-heading"}
      [:a {:href (path-for (str "/user/profile/" user_id)) :target "_blank"} (str first_name " "last_name)]
      [:span.date (date-from-unix-time (* 1000 ctime) "minutes")]
     ]
    (into [:div] (for [ item (clojure.string/split-lines message)]
                   (into [:p.msg] (if (or (re-find #"www." item) (re-find #"https?://" item) (re-find #"http?://" item)) 
                                      (search-and-replace-www item)
                                      item))))]]
    (if (or (=  user_id (:user_id @state)) (= "admin" (:user_role @state)))
        [delete-message-button id state])])

(defn message-list-load-more [state]
  (if (pos? (:messages_left @state))

                   (if (= "success" (:connected? data))
                     (do
                       (f/init-data badge_content_id)
                       (swap! state assoc :start-following true))
                     (swap! state assoc :start-following false))
                   (swap! state assoc
                          :messages []
                          :page_count 0)
                   (init-data state)))
      :error-handler (fn [{:keys [status status-text]}]
                       (dump (str status " " status-text)))})))

(defn delete-message [id state]
  (ajax/POST
   (path-for (str "/obpv1/social/delete_message/" id))
   {:response-format :json
    :keywords? true 
    :handler (fn [data]
               (let [filtered-messages (filter #(not (= id (:id %))) (:messages @state))]
                 (swap! state assoc :messages filtered-messages)))
    :error-handler (fn [{:keys [status status-text]}]
                    (dump (str status " " status-text)))}))

(defn delete-message-button [id state]
  (let [delete-clicked (atom nil)]
