Просмотр исходного кода

chore: diplaying message when cache is outdated; remove buggy unused uuid query

Junyi Du 3 лет назад
Родитель
Сommit
f24a509669
2 измененных файлов с 6 добавлено и 6 удалено
  1. 5 2
      src/main/frontend/components/search.cljs
  2. 1 4
      src/main/frontend/handler/search.cljs

+ 5 - 2
src/main/frontend/components/search.cljs

@@ -1,5 +1,6 @@
 (ns frontend.components.search
   (:require [rum.core :as rum]
+            [lambdaisland.glogi :as log]
             [frontend.util :as util]
             [frontend.components.block :as block]
             [frontend.components.svg :as svg]
@@ -210,8 +211,10 @@
              block (model/query-block-by-uuid uuid)
              content (:block/content block)]
          [:span {:data-block-ref uuid}
-          (search-result-item "Block"
-                              (block-search-result-item repo uuid format content search-q search-mode))])
+          (search-result-item "Block"  (if block
+                                         (block-search-result-item repo uuid format content search-q search-mode)
+                                         (do (log/error "search result with non-existing uuid: " data)
+                                             (str "Re-index required! Cache is outdated."))))])
 
        nil)]))
 

+ 1 - 4
src/main/frontend/handler/search.cljs

@@ -37,10 +37,7 @@
                         (:db/id (db/entity repo [:block/name (util/page-name-sanity-lc page-db-id)]))
                         page-db-id)
            opts (if page-db-id (assoc opts :page (str page-db-id)) opts)]
-       (p/let [blocks (search/block-search repo q opts)
-               blocks (map (fn [b]
-                             (let [format (:block/format (db/entity [:block/uuid (:block/uuid b)]))]
-                               (update b :block/content (partial sanity-search-content format)))) blocks)]
+       (p/let [blocks (search/block-search repo q opts)]
          (let [result (merge
                        {:blocks blocks
                         :has-more? (= limit (count blocks))}