<commit_before>(ns braid.ui.views.search-bar
  (:require-macros [cljs.core.async.macros :refer [go]])
  (:require [reagent.core :as r]
            [clojure.string :as string]
            [cljs.core.async :as async :refer [<! put! chan]]
            [chat.client.dispatcher :refer [dispatch!]]
            [chat.client.store :as store]
            [chat.client.views.helpers :refer [debounce]]
            [chat.client.routes :as routes]))

(defn search-bar-view
  [{:keys [subscribe]}]
  (let [open-group-id (subscribe [:open-group-id])
        search-query (subscribe [:search-query])
        search-chan (chan)]
    (r/create-class
      {:component-will-mount
       (fn []
         (let [search (debounce search-chan 500)]
          (go
            (while true
              (let [{:keys [query]} (<! search)]
                (store/set-search-results! {})
                (if (string/blank? query)
                  (do
                    (routes/go-to! (routes/inbox-page-path {:group-id (routes/current-group)})))
                  (do
                    (routes/go-to! (routes/search-page-path {:group-id (routes/current-group)
                                                             :query query}))
                    (dispatch! :search-history [query @open-group-id]))))))))
       :reagent-render
       (fn []
         [:div.search-bar
           [:input {:type "search"
                    :placeholder "Search History"
                    :value @search-query
                    :on-change
                      (fn [e]
                        (let [query (.. e -target -value)]
                          (store/set-search-query! query)
                          (put! search-chan {:query query})))}]])})))
<commit_msg>replaces routes current group helper with open group id deref<commit_after>(ns braid.ui.views.search-bar
  (:require-macros [cljs.core.async.macros :refer [go]])
  (:require [reagent.core :as r]
            [clojure.string :as string]
            [cljs.core.async :as async :refer [<! put! chan]]
            [chat.client.dispatcher :refer [dispatch!]]
            [chat.client.store :as store]
            [chat.client.views.helpers :refer [debounce]]
            [chat.client.routes :as routes]))

(defn search-bar-view
  [{:keys [subscribe]}]
  (let [open-group-id (subscribe [:open-group-id])
        search-query (subscribe [:search-query])
        search-chan (chan)]
    (r/create-class
      {:component-will-mount
       (fn []
         (let [search (debounce search-chan 500)]
          (go
            (while true
              (let [{:keys [query]} (<! search)]
                (store/set-search-results! {})
                (if (string/blank? query)
                  (do
                    (routes/go-to! (routes/inbox-page-path {:group-id @open-group-id})))
                  (do
                    (routes/go-to! (routes/search-page-path {:group-id @open-group-id
                                                             :query query}))
                    (dispatch! :search-history [query @open-group-id]))))))))
       :reagent-render
       (fn []
         [:div.search-bar
           [:input {:type "search"
                    :placeholder "Search History"
                    :value @search-query
                    :on-change
                      (fn [e]
                        (let [query (.. e -target -value)]
                          (store/set-search-query! query)
                          (put! search-chan {:query query})))}]])})))

{'fraction_non_alphanumeric': 0.14675767918088736, 'fraction_numerical': 0.0017064846416382253, 'mean_word_length': 1.4221763085399448, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6182359', 'n_tokens_mistral': 1024, 'n_tokens_neox': 992, 'n_words': 217}