Skip to content

Commit

Permalink
chore: remove util/in?
Browse files Browse the repository at this point in the history
  • Loading branch information
tiensonqin committed Mar 5, 2021
1 parent 041ef05 commit 093faa1
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/main/frontend/components/block.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -1181,7 +1181,7 @@
only-title? (and (= 1 (count ast))
(= "Properties" (ffirst ast))
(let [m (second (first ast))]
(every? #(util/in? % [:title :filter]) (keys m))))
(every? #(contains? #{:title :filters} %) (keys m))))
block-cp [:div {:class (if only-title?
(util/hiccup->class "pre-block.opacity-50")
(util/hiccup->class "pre-block.bg-base-2.p-2.rounded"))}
Expand Down Expand Up @@ -1841,7 +1841,7 @@
(for [[k v] (dissoc m :roam_alias :roam_tags)]
(when (and (not (and (= k :macros) (empty? v))) ; empty macros
(not (= k :title))
(not (= k :filter)))
(not (= k :filters)))
[:div.property
[:span.font-medium.mr-1 (str (name k) ": ")]
(if (coll? v)
Expand Down
3 changes: 1 addition & 2 deletions src/main/frontend/handler/block.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,7 @@
(when-let [block (db/entity repo [:block/uuid block-id])]
(let [properties (:page/properties (:block/page block))
property-names (keys properties)]
(and (every? #(util/in? % '(:title :filter)) property-names)
(= 1 (count properties))
(and (every? #(contains? #{:title :filters} %) property-names)
(let [ast (mldoc/->edn (:block/content block) (mldoc/default-config (:block/format block)))]
(or
(empty? (rest ast))
Expand Down
6 changes: 3 additions & 3 deletions src/main/frontend/handler/page.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -520,13 +520,13 @@
(defn save-filter!
[page-name filter-state]
(if (empty? filter-state)
(page-remove-property! page-name "filter")
(page-add-properties! page-name {"filter" filter-state})))
(page-remove-property! page-name "filters")
(page-add-properties! page-name {"filters" filter-state})))

(defn get-filter
[page-name]
(let [properties (db/get-page-properties page-name)]
(atom (reader/read-string (get-in properties [:filter] "{}")))))
(atom (reader/read-string (get-in properties [:filters] "{}")))))

(defn page-exists?
[page-name]
Expand Down
6 changes: 0 additions & 6 deletions src/main/frontend/util.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -1151,12 +1151,6 @@
[]
(contains? (set (system-locales)) "zh-CN")))

;; Modified from https://stackoverflow.com/a/3249777/8213163
(defn in?
"true if coll contains elm"
[elm coll]
(true? (some #(= elm %) coll)))

(comment
(= (get-relative-path "journals/2020_11_18.org" "pages/grant_ideas.org")
"../pages/grant_ideas.org")
Expand Down

0 comments on commit 093faa1

Please sign in to comment.