-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
search.cljs
32 lines (29 loc) · 942 Bytes
/
search.cljs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
(ns frontend.handler.search
(:require [goog.object :as gobj]
[frontend.state :as state]
[goog.dom :as gdom]
[frontend.search :as search]
[frontend.handler.notification :as notification-handler]
[promesa.core :as p]))
(defn search
[q]
;; TODO: separate rendering for blocks
(p/let [blocks-result (search/block-search q 10)]
(swap! state/state assoc :search/result
{:pages (search/page-search q)
:files (search/file-search q)
:blocks blocks-result})))
(defn clear-search!
[]
(swap! state/state assoc
:search/result nil
:search/q "")
(when-let [input (gdom/getElement "search_field")]
(gobj/set input "value" "")))
(defn rebuild-indices!
[]
(println "Starting to rebuild search indices!")
(search/rebuild-indices!)
(notification-handler/show!
"Search indices rebuilt successfully!"
:success))