cleaned logging and changed it to use utils.logging; splitted carousel to multiple functions
Former-commit-id: 5aef032c59
This commit is contained in:
parent
bce474e857
commit
38f7ea1ebf
|
@ -4,7 +4,7 @@
|
||||||
scroll-view
|
scroll-view
|
||||||
touchable-without-feedback
|
touchable-without-feedback
|
||||||
text]]
|
text]]
|
||||||
[syng-im.utils.debug :refer [log]]))
|
[syng-im.utils.logging :as log]))
|
||||||
|
|
||||||
|
|
||||||
(defn page-width []
|
(defn page-width []
|
||||||
|
@ -24,21 +24,15 @@
|
||||||
(defn get-page-width [data]
|
(defn get-page-width [data]
|
||||||
(get data :pageWidth (:pageWidth defaults)))
|
(get data :pageWidth (:pageWidth defaults)))
|
||||||
|
|
||||||
|
|
||||||
(defn calculate-gap [component props]
|
(defn calculate-gap [component props]
|
||||||
(let [prop-page-width (get-page-width props)
|
(let [prop-page-width (get-page-width props)
|
||||||
page-width (page-width)
|
page-width (page-width)
|
||||||
sneak (get-sneak props)
|
sneak (get-sneak props)
|
||||||
gap (quot (- (- page-width (* 2 sneak)) prop-page-width) 2)
|
gap (quot (- (- page-width (* 2 sneak)) prop-page-width) 2)]
|
||||||
_ (log "calculate-gap")
|
(log/debug "calculate-gap: prop-page-width=" prop-page-width
|
||||||
_ (log component)
|
"; page-width=" page-width"; sneak=" sneak "; gap=" gap)
|
||||||
_ (log props)
|
(when (> prop-page-width page-width)
|
||||||
_ (log page-width)
|
(log/warn "Invalid pageWidth"))
|
||||||
_ (log prop-page-width)
|
|
||||||
_ (log sneak)
|
|
||||||
_ (log gap)]
|
|
||||||
(if (> prop-page-width page-width)
|
|
||||||
(println "Invalid pageWidth"))
|
|
||||||
(reagent.core/set-state component {:gap gap})
|
(reagent.core/set-state component {:gap gap})
|
||||||
))
|
))
|
||||||
|
|
||||||
|
@ -46,91 +40,80 @@
|
||||||
(.scrollTo (.-scrollView component) (clj->js {:y y
|
(.scrollTo (.-scrollView component) (clj->js {:y y
|
||||||
:x x})))
|
:x x})))
|
||||||
|
|
||||||
|
(defn get-current-position [event]
|
||||||
|
(+ (.-x (.-contentOffset (.-nativeEvent event))) (quot (page-width) 2)))
|
||||||
|
|
||||||
(defn on-scroll-end [event component]
|
(defn on-scroll-end [event component]
|
||||||
(let [_ (log "on-scroll-end")
|
(let [props (reagent.core/props component)
|
||||||
_ (log event)
|
|
||||||
_ (log component)
|
|
||||||
props (reagent.core/props component)
|
|
||||||
_ (log props)
|
|
||||||
state (reagent.core/state component)
|
state (reagent.core/state component)
|
||||||
_ (log state)
|
|
||||||
prop-page-width (get-page-width props)
|
prop-page-width (get-page-width props)
|
||||||
_ (log (str "prop-page-width: " prop-page-width))
|
|
||||||
sneak (get-sneak props)
|
sneak (get-sneak props)
|
||||||
_ (log (str "sneak: " sneak))
|
|
||||||
gap (get-gap state)
|
gap (get-gap state)
|
||||||
_ (log (str "gap: " gap))
|
|
||||||
page-offset (+ prop-page-width gap)
|
page-offset (+ prop-page-width gap)
|
||||||
_ (log (str "page-offset: " page-offset))
|
current-position (get-current-position event)
|
||||||
current-position (+ (.-x (.-contentOffset (.-nativeEvent event))) (quot (page-width) 2))
|
|
||||||
_ (log (str "current-position: " current-position))
|
|
||||||
current-page (quot current-position page-offset)
|
current-page (quot current-position page-offset)
|
||||||
_ (log (str "current-page: " current-page))
|
|
||||||
]
|
]
|
||||||
|
(log/debug "on-scroll-end: prop-page-width=" prop-page-width
|
||||||
|
"; sneak=" sneak "; gap=" gap "; page-offset=" page-offset
|
||||||
|
"; current-position=" current-position
|
||||||
|
"; current-page=" current-page)
|
||||||
(scroll-to component (* current-page page-offset) 0)
|
(scroll-to component (* current-page page-offset) 0)
|
||||||
(reagent.core/set-state component {:activePage current-page})
|
(reagent.core/set-state component {:activePage current-page})
|
||||||
(if (:onPageChange props)
|
(when (:onPageChange props)
|
||||||
((:onPageChange props) current-page))))
|
((:onPageChange props) current-page))))
|
||||||
|
|
||||||
(defn go-to-page [component position]
|
(defn go-to-page [component position]
|
||||||
(let [_ (log "go-to-page")
|
(let [props (reagent.core/props component)
|
||||||
props (reagent.core/props component)
|
|
||||||
state (reagent.core/state component)
|
state (reagent.core/state component)
|
||||||
props-page-width (get-page-width props)
|
props-page-width (get-page-width props)
|
||||||
_ (log (str "props page width: " props-page-width))
|
|
||||||
gap (get-gap state)
|
gap (get-gap state)
|
||||||
_ (log (str "gap: " gap))
|
page-position (* position (+ props-page-width gap))]
|
||||||
page-position (* position (+ props-page-width gap))
|
(log/debug "go-to-page: props-page-width=" props-page-width "; gap=" gap
|
||||||
_ (log (str "page position: " page-position))]
|
"; page-position=" page-position)
|
||||||
(scroll-to component page-position 0)))
|
(scroll-to component page-position 0)))
|
||||||
|
|
||||||
(defn carousel [data children]
|
(defn component-will-mount [component new-args]
|
||||||
(let [_ (log "Creating carousel component: ")
|
(let [props (reagent.core/props component)]
|
||||||
_ (log data)
|
(log/debug "component-will-mount: component=" component "; new-args="new-args)
|
||||||
_ (log children)]
|
(calculate-gap component props)))
|
||||||
(reagent.core/create-class {:component-did-mount (fn [this]
|
|
||||||
(let [_ (log this)]
|
|
||||||
(if (> (.-initialPage (.-props this)) 0)
|
|
||||||
(go-to-page this (.-initialPage (.-props this))))))
|
|
||||||
|
|
||||||
:component-will-mount (fn [this]
|
(defn component-did-mount [component]
|
||||||
(let [_ (log "component-will-mount")
|
(let [props (reagent.core/props component)
|
||||||
_ (log this)]
|
initial-page (.-initialPage props)]
|
||||||
(calculate-gap this (reagent.core/props this))))
|
(log/debug "component-did-mount: initial-page="initial-page)
|
||||||
:component-will-receive-props (fn [this new-argv]
|
(when (pos? initial-page)
|
||||||
(let [_ (log "component-will-receive-props-mount")
|
(go-to-page component initial-page))))
|
||||||
_ (log this)
|
|
||||||
_ (log new-argv)]
|
(defn component-will-receive-props [component new-argv]
|
||||||
(calculate-gap this new-argv)))
|
(log/debug "component-will-receive-props: component=" component
|
||||||
:display-name "carousel1"
|
"; new-argv=" new-argv)
|
||||||
:reagent-render (fn [data children]
|
(calculate-gap component new-argv))
|
||||||
(let [_ (log "reagent-render")
|
|
||||||
_ (log data)
|
(defn get-pages [component data children]
|
||||||
_ (log children)
|
(let [props-page-width (get-page-width data)
|
||||||
component (reagent.core/current-component)
|
|
||||||
props-page-width (get-page-width data)
|
|
||||||
sneak (get-sneak data)
|
|
||||||
gap (get-gap data)
|
|
||||||
page-style (get data :pageStyle {})
|
page-style (get data :pageStyle {})
|
||||||
pages (map-indexed (fn [index child]
|
gap (get-gap data)
|
||||||
|
margin (quot gap 2)]
|
||||||
|
(map-indexed (fn [index child]
|
||||||
(let [page-index index
|
(let [page-index index
|
||||||
_ (log (str "page index" index "-" page-index))
|
touchable-data {:key index
|
||||||
_ (log child)]
|
:onPress (fn [event]
|
||||||
[touchable-without-feedback {:key index
|
(go-to-page component page-index))}]
|
||||||
:onPress (fn [a b c]
|
(log/debug "page " index " - " child)
|
||||||
(let [_ (log "touchable pressed")
|
[touchable-without-feedback touchable-data
|
||||||
_ (log (.-target a))
|
|
||||||
_ (log component)
|
|
||||||
_ (log page-index)]
|
|
||||||
(go-to-page component page-index)))
|
|
||||||
}
|
|
||||||
[view {:style [{:width props-page-width
|
[view {:style [{:width props-page-width
|
||||||
:justifyContent "center"
|
:justifyContent "center"
|
||||||
:marginLeft (quot gap 2)
|
:marginLeft margin
|
||||||
:marginRight (quot gap 2)}
|
:marginRight margin}
|
||||||
page-style]}
|
page-style]}
|
||||||
child]])) children)]
|
child]])) children)))
|
||||||
|
|
||||||
|
(defn reagent-render [data children]
|
||||||
|
(let [component (reagent.core/current-component)
|
||||||
|
sneak (get-sneak data)
|
||||||
|
gap (get-gap data)
|
||||||
|
pages (get-pages component data children)]
|
||||||
|
(log/debug "reagent-render: ")
|
||||||
[view {:style {:flex 1}}
|
[view {:style {:flex 1}}
|
||||||
[scroll-view {:contentContainerStyle {:paddingLeft (+ sneak (quot gap 2))
|
[scroll-view {:contentContainerStyle {:paddingLeft (+ sneak (quot gap 2))
|
||||||
:paddingRight (+ sneak (quot gap 2))}
|
:paddingRight (+ sneak (quot gap 2))}
|
||||||
|
@ -142,9 +125,14 @@
|
||||||
:showsHorizontalScrollIndicator false
|
:showsHorizontalScrollIndicator false
|
||||||
:ref (fn [c] (set! (.-scrollView component) c))
|
:ref (fn [c] (set! (.-scrollView component) c))
|
||||||
}
|
}
|
||||||
pages]]))})))
|
pages]]
|
||||||
|
))
|
||||||
|
|
||||||
(comment
|
(defn carousel [data children]
|
||||||
|
(let [component-data {:component-did-mount component-did-mount
|
||||||
|
:component-will-mount component-will-mount
|
||||||
)
|
:component-will-receive-props component-will-receive-props
|
||||||
|
:display-name "carousel"
|
||||||
|
:reagent-render reagent-render}]
|
||||||
|
(log/debug "Creating carousel component: " data children)
|
||||||
|
(reagent.core/create-class component-data)))
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
(ns syng-im.components.discovery.discovery-popular-list-item
|
(ns syng-im.components.discovery.discovery-popular-list-item
|
||||||
(:require
|
(:require
|
||||||
[syng-im.utils.debug :refer [log]]
|
[syng-im.utils.logging :as log]
|
||||||
[syng-im.components.react :refer [android?
|
[syng-im.components.react :refer [android?
|
||||||
view
|
view
|
||||||
text
|
text
|
||||||
|
@ -10,7 +10,7 @@
|
||||||
)
|
)
|
||||||
|
|
||||||
(defn discovery-popular-list-item [discovery]
|
(defn discovery-popular-list-item [discovery]
|
||||||
(let [_ (log discovery)]
|
(log/debug discovery)
|
||||||
(r/as-element [view {:style {:flexDirection "row"
|
(r/as-element [view {:style {:flexDirection "row"
|
||||||
:paddingTop 10
|
:paddingTop 10
|
||||||
:paddingBottom 10}}
|
:paddingBottom 10}}
|
||||||
|
@ -34,5 +34,4 @@
|
||||||
:height 30}
|
:height 30}
|
||||||
:source res/user-no-photo}]
|
:source res/user-no-photo}]
|
||||||
]
|
]
|
||||||
])
|
]))
|
||||||
))
|
|
|
@ -1,7 +1,7 @@
|
||||||
(ns syng-im.components.discovery.discovery
|
(ns syng-im.components.discovery.discovery
|
||||||
|
|
||||||
(:require
|
(:require
|
||||||
[syng-im.utils.debug :refer [log]]
|
[syng-im.utils.logging :as log]
|
||||||
[re-frame.core :refer [dispatch]]
|
[re-frame.core :refer [dispatch]]
|
||||||
[syng-im.models.discoveries :refer [save-discoveries]]
|
[syng-im.models.discoveries :refer [save-discoveries]]
|
||||||
[syng-im.components.react :refer [android?
|
[syng-im.components.react :refer [android?
|
||||||
|
@ -67,7 +67,7 @@
|
||||||
:placeholder "Type your search tags here"
|
:placeholder "Type your search tags here"
|
||||||
:onChangeText (fn [new-text]
|
:onChangeText (fn [new-text]
|
||||||
(let [old-text (:search @search-input)]
|
(let [old-text (:search @search-input)]
|
||||||
(log (str new-text "-" old-text))))
|
(log/debug (str new-text "-" old-text))))
|
||||||
:onSubmitEditing (fn [e]
|
:onSubmitEditing (fn [e]
|
||||||
(let [search (aget e "nativeEvent" "text")
|
(let [search (aget e "nativeEvent" "text")
|
||||||
hashtags (get-hashtags search)]
|
hashtags (get-hashtags search)]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
(ns syng-im.components.discovery.discovery-popular
|
(ns syng-im.components.discovery.discovery-popular
|
||||||
(:require
|
(:require
|
||||||
[re-frame.core :refer [subscribe]]
|
[re-frame.core :refer [subscribe]]
|
||||||
[syng-im.utils.debug :refer [log]]
|
[syng-im.utils.logging :as log]
|
||||||
[syng-im.components.react :refer [android?
|
[syng-im.components.react :refer [android?
|
||||||
text]]
|
text]]
|
||||||
[syng-im.components.carousel :refer [carousel]]
|
[syng-im.components.carousel :refer [carousel]]
|
||||||
|
@ -12,9 +12,8 @@
|
||||||
(.-width (.get (.. js/React -Dimensions) "window")))
|
(.-width (.get (.. js/React -Dimensions) "window")))
|
||||||
|
|
||||||
(defn discovery-popular []
|
(defn discovery-popular []
|
||||||
(let [popular-tags (subscribe [:get-popular-tags 3])
|
(let [popular-tags (subscribe [:get-popular-tags 3])]
|
||||||
_ (log "Got popular tags: ")
|
(log/debug "Got popular tags: " @popular-tags)
|
||||||
_ (log @popular-tags)]
|
|
||||||
(if (> (count @popular-tags) 0)
|
(if (> (count @popular-tags) 0)
|
||||||
[carousel {:pageStyle {:borderRadius 1
|
[carousel {:pageStyle {:borderRadius 1
|
||||||
:shadowColor "black"
|
:shadowColor "black"
|
||||||
|
@ -25,14 +24,8 @@
|
||||||
:pageWidth (- (page-width) 60)
|
:pageWidth (- (page-width) 60)
|
||||||
:sneak 20}
|
:sneak 20}
|
||||||
(for [tag @popular-tags]
|
(for [tag @popular-tags]
|
||||||
(discovery-popular-list (.-name tag)))
|
(discovery-popular-list (.-name tag)))]
|
||||||
]
|
|
||||||
[text "None"]
|
[text "None"]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
(comment
|
|
||||||
(set! React (js/require "react-native"))
|
|
||||||
(.get (.Dimensions React) "window")
|
|
||||||
)
|
|
|
@ -1,10 +1,7 @@
|
||||||
(ns syng-im.components.discovery.discovery-popular-list
|
(ns syng-im.components.discovery.discovery-popular-list
|
||||||
(:require-macros
|
|
||||||
[natal-shell.data-source :refer [data-source clone-with-rows]]
|
|
||||||
)
|
|
||||||
(:require
|
(:require
|
||||||
[re-frame.core :refer [subscribe dispatch dispatch-sync]]
|
[re-frame.core :refer [subscribe dispatch dispatch-sync]]
|
||||||
[syng-im.utils.debug :refer [log]]
|
[syng-im.utils.logging :as log]
|
||||||
[syng-im.components.react :refer [android?
|
[syng-im.components.react :refer [android?
|
||||||
view
|
view
|
||||||
list-view
|
list-view
|
||||||
|
@ -29,9 +26,8 @@
|
||||||
elem))
|
elem))
|
||||||
|
|
||||||
(defn discovery-popular-list [tag]
|
(defn discovery-popular-list [tag]
|
||||||
(let [discoveries (subscribe [:get-discoveries-by-tag tag 3])
|
(let [discoveries (subscribe [:get-discoveries-by-tag tag 3])]
|
||||||
_ (log (str "Got discoveries for tag (" tag "): ") @discoveries)
|
(log/debug "Got discoveries for tag (" tag "): " @discoveries)
|
||||||
_ (log @discoveries)]
|
|
||||||
[view {:style {:flex 1
|
[view {:style {:flex 1
|
||||||
:backgroundColor "white"
|
:backgroundColor "white"
|
||||||
:paddingLeft 10
|
:paddingLeft 10
|
||||||
|
@ -47,15 +43,10 @@
|
||||||
:paddingRight 5
|
:paddingRight 5
|
||||||
:paddingBottom 2
|
:paddingBottom 2
|
||||||
:alignItems "center"
|
:alignItems "center"
|
||||||
:justifyContent "center"}} (str " #" (name tag))]]]
|
:justifyContent "center"}}
|
||||||
|
(str " #" (name tag))]]]
|
||||||
[list-view {:dataSource (to-realm-datasource @discoveries)
|
[list-view {:dataSource (to-realm-datasource @discoveries)
|
||||||
:renderRow render-row
|
:renderRow render-row
|
||||||
:renderSeparator render-separator
|
:renderSeparator render-separator
|
||||||
:style {:backgroundColor "white"}}]
|
:style {:backgroundColor "white"}}]
|
||||||
]))
|
]))
|
||||||
|
|
||||||
(comment
|
|
||||||
list-view {:dataSource elements
|
|
||||||
:renderRow (partial render-row list-element)
|
|
||||||
:style {:backgroundColor "white"}}
|
|
||||||
)
|
|
|
@ -1,6 +1,6 @@
|
||||||
(ns syng-im.handlers.discovery
|
(ns syng-im.handlers.discovery
|
||||||
(:require [re-frame.core :refer [register-handler after dispatch]]
|
(:require [re-frame.core :refer [register-handler after dispatch]]
|
||||||
[syng-im.utils.debug :refer [log]]
|
[syng-im.utils.logging :as log]
|
||||||
[syng-im.protocol.api :as api]
|
[syng-im.protocol.api :as api]
|
||||||
[syng-im.models.discoveries :refer [save-discoveries
|
[syng-im.models.discoveries :refer [save-discoveries
|
||||||
signal-discoveries-updated]]))
|
signal-discoveries-updated]]))
|
||||||
|
@ -27,8 +27,7 @@
|
||||||
|
|
||||||
(register-handler :broadcast-status
|
(register-handler :broadcast-status
|
||||||
(fn [db [action status hashtags]]
|
(fn [db [action status hashtags]]
|
||||||
(let [_ (log "Status: " status)
|
(let [name (:name db)]
|
||||||
_ (log "Hashtags: " hashtags)
|
(log/debug "Status: " status ", Hashtags: " hashtags)
|
||||||
name (:name db)]
|
|
||||||
(api/broadcast-discover-status name status hashtags)
|
(api/broadcast-discover-status name status hashtags)
|
||||||
db)))
|
db)))
|
|
@ -1,7 +1,7 @@
|
||||||
(ns syng-im.models.discoveries
|
(ns syng-im.models.discoveries
|
||||||
(:require [cljs.core.async :as async :refer [chan put! <! >!]]
|
(:require [cljs.core.async :as async :refer [chan put! <! >!]]
|
||||||
[re-frame.core :refer [subscribe dispatch dispatch-sync]]
|
[re-frame.core :refer [subscribe dispatch dispatch-sync]]
|
||||||
[syng-im.utils.debug :refer [log]]
|
[syng-im.utils.logging :as log]
|
||||||
[syng-im.persistence.realm :as realm]
|
[syng-im.persistence.realm :as realm]
|
||||||
[syng-im.persistence.realm :as r]
|
[syng-im.persistence.realm :as r]
|
||||||
[syng-im.resources :as res]
|
[syng-im.resources :as res]
|
||||||
|
@ -17,9 +17,9 @@
|
||||||
(get-in db db/updated-discoveries-signal-path))
|
(get-in db db/updated-discoveries-signal-path))
|
||||||
|
|
||||||
(defn get-tag [tag]
|
(defn get-tag [tag]
|
||||||
(let [_ (log (str "Getting tag: " tag))]
|
(log/debug "Getting tag: " tag)
|
||||||
(-> (r/get-by-field :tag :name tag)
|
(-> (r/get-by-field :tag :name tag)
|
||||||
(r/single-cljs))))
|
(r/single-cljs)))
|
||||||
|
|
||||||
(defn decrease-tag-counter [tag]
|
(defn decrease-tag-counter [tag]
|
||||||
(let [tag (:name tag)
|
(let [tag (:name tag)
|
||||||
|
@ -60,13 +60,10 @@
|
||||||
:photo photo
|
:photo photo
|
||||||
:location location
|
:location location
|
||||||
:tags tags
|
:tags tags
|
||||||
:last-updated last-updated}
|
:last-updated last-updated}]
|
||||||
_ (log "Creating discovery")
|
(log/debug "Creating discovery: " discovery tags)
|
||||||
_ (log discovery)
|
|
||||||
_ (log tags)]
|
|
||||||
(do
|
|
||||||
(realm/create :discoveries discovery true)
|
(realm/create :discoveries discovery true)
|
||||||
(increase-tags-counter tags))))
|
(increase-tags-counter tags)))
|
||||||
|
|
||||||
(defn- update-discovery [{:keys [name status whisper-id photo location tags last-updated]}]
|
(defn- update-discovery [{:keys [name status whisper-id photo location tags last-updated]}]
|
||||||
(let [old-tags (get-tags whisper-id)
|
(let [old-tags (get-tags whisper-id)
|
||||||
|
@ -78,10 +75,9 @@
|
||||||
:location location
|
:location location
|
||||||
:tags tags
|
:tags tags
|
||||||
:last-updated last-updated}]
|
:last-updated last-updated}]
|
||||||
(do
|
|
||||||
(decrease-tags-counter old-tags)
|
(decrease-tags-counter old-tags)
|
||||||
(realm/create :discoveries discovery true)
|
(realm/create :discoveries discovery true)
|
||||||
(increase-tags-counter tags))))
|
(increase-tags-counter tags)))
|
||||||
|
|
||||||
(defn- discovery-exist? [discoveries discovery]
|
(defn- discovery-exist? [discoveries discovery]
|
||||||
(some #(= (:whisper-id discovery) (:whisper-id %)) discoveries))
|
(some #(= (:whisper-id discovery) (:whisper-id %)) discoveries))
|
||||||
|
@ -92,9 +88,7 @@
|
||||||
|
|
||||||
(defn- add-discoveries [discoveries]
|
(defn- add-discoveries [discoveries]
|
||||||
(realm/write (fn []
|
(realm/write (fn []
|
||||||
(let [db-discoveries (.slice (discovery-list) 0)
|
(let [db-discoveries (.slice (discovery-list) 0)]
|
||||||
_ (log discoveries)
|
|
||||||
_ (log (.slice db-discoveries 0))]
|
|
||||||
(dorun (map (fn [discovery]
|
(dorun (map (fn [discovery]
|
||||||
(if (not (discovery-exist? db-discoveries discovery))
|
(if (not (discovery-exist? db-discoveries discovery))
|
||||||
(create-discovery discovery)
|
(create-discovery discovery)
|
||||||
|
@ -106,10 +100,10 @@
|
||||||
(add-discoveries discoveries))
|
(add-discoveries discoveries))
|
||||||
|
|
||||||
(defn discoveries-by-tag [tag limit]
|
(defn discoveries-by-tag [tag limit]
|
||||||
(let [_ (log (str "discoveries by tag: " tag))]
|
(log/debug "Discoveries by tag: " tag)
|
||||||
(-> (r/get-by-filter :discoveries (str "tags.name = '" tag "'"))
|
(-> (r/get-by-filter :discoveries (str "tags.name = '" tag "'"))
|
||||||
(r/sorted :last-updated :desc)
|
(r/sorted :last-updated :desc)
|
||||||
(r/page 0 limit))))
|
(r/page 0 limit)))
|
||||||
|
|
||||||
(defn get-tag-popular [limit]
|
(defn get-tag-popular [limit]
|
||||||
(-> (r/get-all :tag)
|
(-> (r/get-all :tag)
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
(ns syng-im.persistence.realm
|
(ns syng-im.persistence.realm
|
||||||
(:require [cljs.reader :refer [read-string]]
|
(:require [cljs.reader :refer [read-string]]
|
||||||
[syng-im.utils.debug :refer [log]]
|
|
||||||
[syng-im.utils.types :refer [to-string]])
|
[syng-im.utils.types :refer [to-string]])
|
||||||
(:refer-clojure :exclude [exists?]))
|
(:refer-clojure :exclude [exists?]))
|
||||||
|
|
||||||
|
@ -100,9 +99,8 @@
|
||||||
query))
|
query))
|
||||||
|
|
||||||
(defn get-by-filter [schema-name filter]
|
(defn get-by-filter [schema-name filter]
|
||||||
(let [_ (log filter)]
|
|
||||||
(-> (.objects realm (name schema-name))
|
(-> (.objects realm (name schema-name))
|
||||||
(.filtered filter))))
|
(.filtered filter)))
|
||||||
|
|
||||||
(defn get-by-field [schema-name field value]
|
(defn get-by-field [schema-name field value]
|
||||||
(let [q (to-query schema-name :eq field value)]
|
(let [q (to-query schema-name :eq field value)]
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
(:require-macros [reagent.ratom :refer [reaction]])
|
(:require-macros [reagent.ratom :refer [reaction]])
|
||||||
(:require [re-frame.core :refer [register-sub]]
|
(:require [re-frame.core :refer [register-sub]]
|
||||||
[syng-im.db :as db]
|
[syng-im.db :as db]
|
||||||
[syng-im.utils.debug :refer [log]]
|
[syng-im.utils.logging :as log]
|
||||||
[syng-im.models.discoveries :refer [discovery-list
|
[syng-im.models.discoveries :refer [discovery-list
|
||||||
get-tag-popular
|
get-tag-popular
|
||||||
discoveries-by-tag
|
discoveries-by-tag
|
||||||
|
@ -21,8 +21,8 @@
|
||||||
(register-sub :get-discoveries-by-tag
|
(register-sub :get-discoveries-by-tag
|
||||||
(fn [db [_ tag limit]]
|
(fn [db [_ tag limit]]
|
||||||
(let [discoveries-updated (-> (discoveries-updated? @db)
|
(let [discoveries-updated (-> (discoveries-updated? @db)
|
||||||
(reaction))
|
(reaction))]
|
||||||
_ (log (str "getting discoveries for: " tag))]
|
(log/debug "Getting discoveries for: " tag)
|
||||||
(reaction
|
(reaction
|
||||||
(let [_ @discoveries-updated]
|
(let [_ @discoveries-updated]
|
||||||
(discoveries-by-tag tag limit))))))
|
(discoveries-by-tag tag limit))))))
|
||||||
|
@ -30,8 +30,8 @@
|
||||||
(register-sub :get-popular-tags
|
(register-sub :get-popular-tags
|
||||||
(fn [db [_ limit]]
|
(fn [db [_ limit]]
|
||||||
(let [discoveries-updated (-> (discoveries-updated? @db)
|
(let [discoveries-updated (-> (discoveries-updated? @db)
|
||||||
(reaction))
|
(reaction))]
|
||||||
_ (log (str "getting tags limited: " limit))]
|
(log/debug "Getting tags limited: " limit)
|
||||||
(reaction
|
(reaction
|
||||||
(let [_ @discoveries-updated]
|
(let [_ @discoveries-updated]
|
||||||
(get-tag-popular limit))))))
|
(get-tag-popular limit))))))
|
|
@ -1,3 +0,0 @@
|
||||||
(ns syng-im.utils.debug)
|
|
||||||
|
|
||||||
(def log (.-log js/console))
|
|
Loading…
Reference in New Issue