parent
9031ab5144
commit
ee5a169c8e
|
@ -1,10 +1,8 @@
|
||||||
(ns syng-im.discovery.handlers
|
(ns syng-im.discovery.handlers
|
||||||
(:require [re-frame.core :refer [register-handler after dispatch enrich
|
(:require [re-frame.core :refer [register-handler after dispatch enrich]]
|
||||||
log-ex debug]]
|
|
||||||
[syng-im.protocol.api :as api]
|
[syng-im.protocol.api :as api]
|
||||||
[syng-im.models.discoveries :refer [save-discoveries]]
|
|
||||||
[syng-im.navigation.handlers :as nav]
|
[syng-im.navigation.handlers :as nav]
|
||||||
[syng-im.models.discoveries :as discoveries]
|
[syng-im.discovery.model :as discoveries]
|
||||||
[syng-im.utils.handlers :as u]))
|
[syng-im.utils.handlers :as u]))
|
||||||
|
|
||||||
(defmethod nav/preload-data! :discovery
|
(defmethod nav/preload-data! :discovery
|
||||||
|
@ -12,6 +10,9 @@
|
||||||
(if-not (seq discoveries)
|
(if-not (seq discoveries)
|
||||||
(-> db
|
(-> db
|
||||||
(assoc :tags (discoveries/all-tags))
|
(assoc :tags (discoveries/all-tags))
|
||||||
|
;; todo add limit
|
||||||
|
;; todo hash-map with whisper-id as key and sorted by last-update
|
||||||
|
;; may be more efficient here
|
||||||
(assoc :discoveries (discoveries/discovery-list)))
|
(assoc :discoveries (discoveries/discovery-list)))
|
||||||
db))
|
db))
|
||||||
|
|
||||||
|
@ -71,6 +72,5 @@
|
||||||
|
|
||||||
(register-handler :add-discovery
|
(register-handler :add-discovery
|
||||||
(-> add-discovery
|
(-> add-discovery
|
||||||
debug
|
|
||||||
((after save-discovery!))
|
((after save-discovery!))
|
||||||
((enrich reload-tags!))))
|
((enrich reload-tags!))))
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
(ns syng-im.models.discoveries
|
(ns syng-im.discovery.model
|
||||||
(:require [re-frame.core :refer [subscribe dispatch dispatch-sync]]
|
;syng-im.models.discoveries
|
||||||
[syng-im.utils.logging :as log]
|
(:require [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.db :as db]))
|
|
||||||
|
|
||||||
(defn get-tag [tag]
|
(defn get-tag [tag]
|
||||||
(log/debug "Getting tag: " tag)
|
(log/debug "Getting tag: " tag)
|
||||||
|
@ -88,8 +87,3 @@
|
||||||
(r/sorted :count :desc)
|
(r/sorted :count :desc)
|
||||||
r/collection->map))
|
r/collection->map))
|
||||||
|
|
||||||
(defn get-tag-popular [limit]
|
|
||||||
(-> (r/get-all :tag)
|
|
||||||
(r/sorted :count :desc)
|
|
||||||
(r/page 0 limit)))
|
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
(defn discovery-recent []
|
(defn discovery-recent []
|
||||||
(let [discoveries (subscribe [:get :discoveries])]
|
(let [discoveries (subscribe [:get :discoveries])]
|
||||||
(fn []
|
(fn []
|
||||||
|
;; todo fetch more on :onEndReached
|
||||||
[list-view {:dataSource (to-datasource2 @discoveries)
|
[list-view {:dataSource (to-datasource2 @discoveries)
|
||||||
:renderRow render-row
|
:renderRow render-row
|
||||||
:renderSeparator render-separator
|
:renderSeparator render-separator
|
||||||
|
|
|
@ -8,9 +8,7 @@
|
||||||
[syng-im.models.protocol :refer [update-identity
|
[syng-im.models.protocol :refer [update-identity
|
||||||
set-initialized]]
|
set-initialized]]
|
||||||
[syng-im.models.contacts :as contacts]
|
[syng-im.models.contacts :as contacts]
|
||||||
[syng-im.models.messages :refer [save-message
|
[syng-im.models.messages :refer [save-message update-message!]]
|
||||||
update-message!
|
|
||||||
message-by-id]]
|
|
||||||
[syng-im.models.commands :refer [set-commands]]
|
[syng-im.models.commands :refer [set-commands]]
|
||||||
[syng-im.handlers.server :as server]
|
[syng-im.handlers.server :as server]
|
||||||
[syng-im.chat.suggestions :refer [get-command
|
[syng-im.chat.suggestions :refer [get-command
|
||||||
|
|
|
@ -51,9 +51,6 @@
|
||||||
(update message :content str-to-map)
|
(update message :content str-to-map)
|
||||||
message)))))
|
message)))))
|
||||||
|
|
||||||
(defn message-by-id [msg-id]
|
|
||||||
(r/single-cljs (r/get-by-field :msgs :msg-id msg-id)))
|
|
||||||
|
|
||||||
(defn update-message! [{:keys [msg-id] :as msg}]
|
(defn update-message! [{:keys [msg-id] :as msg}]
|
||||||
(log/debug "update-message!" msg)
|
(log/debug "update-message!" msg)
|
||||||
(r/write
|
(r/write
|
||||||
|
|
Loading…
Reference in New Issue