parent
3fc884db25
commit
4fd5bd6f00
|
@ -9,7 +9,7 @@
|
||||||
[syng-im.components.react :refer [navigator app-registry]]
|
[syng-im.components.react :refer [navigator app-registry]]
|
||||||
[syng-im.contacts.screen :refer [contact-list]]
|
[syng-im.contacts.screen :refer [contact-list]]
|
||||||
[syng-im.discovery.screen :refer [discovery]]
|
[syng-im.discovery.screen :refer [discovery]]
|
||||||
[syng-im.discovery.discovery-tag :refer [discovery-tag]]
|
[syng-im.discovery.tag :refer [discovery-tag]]
|
||||||
[syng-im.chat.screen :refer [chat]]
|
[syng-im.chat.screen :refer [chat]]
|
||||||
[syng-im.chats-list.screen :refer [chats-list]]
|
[syng-im.chats-list.screen :refer [chats-list]]
|
||||||
[syng-im.new-group.screen :refer [new-group]]
|
[syng-im.new-group.screen :refer [new-group]]
|
||||||
|
|
|
@ -39,6 +39,4 @@
|
||||||
[:chats chat-id :command-requests])
|
[:chats chat-id :command-requests])
|
||||||
(defn chat-command-request-path [chat-id msg-id]
|
(defn chat-command-request-path [chat-id msg-id]
|
||||||
[:chats chat-id :command-requests msg-id])
|
[:chats chat-id :command-requests msg-id])
|
||||||
(def updated-discoveries-signal-path [:discovery-updated-signal])
|
|
||||||
(def current-tag-path [:current-tag])
|
|
||||||
(def updated-current-tag-signal-path [:current-tag-updated-signal])
|
(def updated-current-tag-signal-path [:current-tag-updated-signal])
|
||||||
|
|
|
@ -1,57 +0,0 @@
|
||||||
(ns syng-im.discovery.discovery-tag
|
|
||||||
(:require
|
|
||||||
[re-frame.core :refer [subscribe]]
|
|
||||||
[syng-im.utils.logging :as log]
|
|
||||||
[syng-im.utils.listview :refer [to-realm-datasource
|
|
||||||
to-datasource]]
|
|
||||||
[syng-im.navigation :refer [nav-pop]]
|
|
||||||
[syng-im.components.react :refer [android?
|
|
||||||
view
|
|
||||||
text]]
|
|
||||||
[syng-im.components.realm :refer [list-view]]
|
|
||||||
[syng-im.components.toolbar :refer [toolbar]]
|
|
||||||
[reagent.core :as r]
|
|
||||||
[syng-im.discovery.discovery-popular-list-item :refer [discovery-popular-list-item]]
|
|
||||||
[syng-im.discovery.styles :as st]))
|
|
||||||
|
|
||||||
(defn render-row [row section-id row-id]
|
|
||||||
(log/debug "discovery-tag-row: " row section-id row-id)
|
|
||||||
(if row
|
|
||||||
(let [elem (discovery-popular-list-item row)]
|
|
||||||
elem)
|
|
||||||
(r/as-element [text "null"])
|
|
||||||
))
|
|
||||||
|
|
||||||
(defn render-separator [sectionID, rowID, adjacentRowHighlighted]
|
|
||||||
(let [elem (r/as-element [view {:style st/row-separator
|
|
||||||
:key rowID}])]
|
|
||||||
elem))
|
|
||||||
|
|
||||||
(defn title-content [tag]
|
|
||||||
[view {:style st/tag-title-container}
|
|
||||||
[text {:style st/tag-title}
|
|
||||||
(str " #" tag)]])
|
|
||||||
|
|
||||||
(defn discovery-tag [{:keys [tag navigator]}]
|
|
||||||
(let [tag (subscribe [:get-current-tag])
|
|
||||||
discoveries (subscribe [:get-discoveries-by-tag @tag 0])]
|
|
||||||
(log/debug "Got discoveries: " @discoveries)
|
|
||||||
(fn []
|
|
||||||
(let [items @discoveries
|
|
||||||
datasource (to-realm-datasource items)]
|
|
||||||
[view {:style st/discovery-tag-container}
|
|
||||||
[toolbar {:navigator navigator
|
|
||||||
:nav-action {:image {:source {:uri "icon_back"}
|
|
||||||
:style st/icon-back}
|
|
||||||
:handler (fn [] (nav-pop navigator))}
|
|
||||||
:title "Add Participants"
|
|
||||||
:content (title-content @tag)
|
|
||||||
:action {:image {:source {:uri "icon_search"}
|
|
||||||
:style st/icon-search}
|
|
||||||
:handler (fn []
|
|
||||||
())}}]
|
|
||||||
|
|
||||||
[list-view {:dataSource datasource
|
|
||||||
:renderRow render-row
|
|
||||||
:renderSeparator render-separator
|
|
||||||
:style st/recent-list}]]))))
|
|
|
@ -2,17 +2,18 @@
|
||||||
(:require [re-frame.core :refer [register-handler after dispatch enrich
|
(:require [re-frame.core :refer [register-handler after dispatch enrich
|
||||||
log-ex debug]]
|
log-ex debug]]
|
||||||
[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]]
|
||||||
set-current-tag]]
|
|
||||||
[syng-im.navigation.handlers :as nav]
|
[syng-im.navigation.handlers :as nav]
|
||||||
[syng-im.models.discoveries :as discoveries]
|
[syng-im.models.discoveries :as discoveries]
|
||||||
[syng-im.utils.handlers :as u]))
|
[syng-im.utils.handlers :as u]))
|
||||||
|
|
||||||
(defmethod nav/preload-data! :discovery
|
(defmethod nav/preload-data! :discovery
|
||||||
[{:keys [] :as db} _]
|
[{:keys [discoveries] :as db} _]
|
||||||
|
(if-not (seq discoveries)
|
||||||
(-> db
|
(-> db
|
||||||
(assoc :tags (discoveries/all-tags))
|
(assoc :tags (discoveries/all-tags))
|
||||||
(assoc :discoveries (discoveries/discovery-list))))
|
(assoc :discoveries (discoveries/discovery-list)))
|
||||||
|
db))
|
||||||
|
|
||||||
(register-handler :discovery-response-received
|
(register-handler :discovery-response-received
|
||||||
(u/side-effect!
|
(u/side-effect!
|
||||||
|
@ -29,15 +30,14 @@
|
||||||
(dispatch [:add-discovery discovery])))))
|
(dispatch [:add-discovery discovery])))))
|
||||||
|
|
||||||
(register-handler :broadcast-status
|
(register-handler :broadcast-status
|
||||||
(fn [{:keys [name] :as db} [_ status hashtags]]
|
(u/side-effect!
|
||||||
(api/broadcast-discover-status name status hashtags)
|
(fn [{:keys [name]} [_ status hashtags]]
|
||||||
db))
|
(api/broadcast-discover-status name status hashtags))))
|
||||||
|
|
||||||
(register-handler :show-discovery-tag
|
(register-handler :show-discovery-tag
|
||||||
(fn [db [_ tag]]
|
(fn [db [_ tag]]
|
||||||
(let [db (set-current-tag db tag)]
|
|
||||||
(dispatch [:navigate-to :discovery-tag])
|
(dispatch [:navigate-to :discovery-tag])
|
||||||
db)))
|
(assoc db :current-tag tag)))
|
||||||
|
|
||||||
;; todo remove this
|
;; todo remove this
|
||||||
(register-handler :create-fake-discovery!
|
(register-handler :create-fake-discovery!
|
||||||
|
|
|
@ -1,27 +1,21 @@
|
||||||
(ns syng-im.discovery.screen
|
(ns syng-im.discovery.screen
|
||||||
|
|
||||||
(:require
|
(:require
|
||||||
[syng-im.utils.logging :as log]
|
|
||||||
[re-frame.core :refer [dispatch subscribe]]
|
[re-frame.core :refer [dispatch subscribe]]
|
||||||
[syng-im.models.discoveries :refer [save-discoveries]]
|
[syng-im.components.react :refer [view
|
||||||
[syng-im.components.react :refer [android?
|
|
||||||
view
|
|
||||||
scroll-view
|
scroll-view
|
||||||
text
|
text
|
||||||
text-input]]
|
text-input]]
|
||||||
[reagent.core :as r]
|
|
||||||
[syng-im.components.toolbar :refer [toolbar]]
|
[syng-im.components.toolbar :refer [toolbar]]
|
||||||
[syng-im.discovery.views.popular :refer [popular]]
|
[syng-im.discovery.views.popular :refer [popular]]
|
||||||
[syng-im.discovery.discovery-recent :refer [discovery-recent]]
|
[syng-im.discovery.views.recent :refer [discovery-recent]]
|
||||||
[syng-im.discovery.styles :as st]
|
[syng-im.discovery.styles :as st]))
|
||||||
[syng-im.persistence.realm :as realm]))
|
|
||||||
|
|
||||||
(defn get-hashtags [status]
|
(defn get-hashtags [status]
|
||||||
(let [hashtags (map #(subs % 1) (re-seq #"#[^ !?,;:.]+" status))]
|
(let [hashtags (map #(subs % 1) (re-seq #"#[^ !?,;:.]+" status))]
|
||||||
(or hashtags [])))
|
(or hashtags [])))
|
||||||
|
|
||||||
(defn title-content [showSearch]
|
(defn title-content [show-search]
|
||||||
(if showSearch
|
(if show-search
|
||||||
[text-input {:style st/discovery-search-input
|
[text-input {:style st/discovery-search-input
|
||||||
:autoFocus true
|
:autoFocus true
|
||||||
:placeholder "Type your search tags here"
|
:placeholder "Type your search tags here"
|
||||||
|
@ -48,7 +42,7 @@
|
||||||
:height 12}}
|
:height 12}}
|
||||||
:handler #(dispatch [:create-fake-discovery!])}
|
:handler #(dispatch [:create-fake-discovery!])}
|
||||||
:title "Add Participants"
|
:title "Add Participants"
|
||||||
:content (title-content @show-search)
|
:content [title-content @show-search]
|
||||||
:action {:image {:source {:uri :icon_search}
|
:action {:image {:source {:uri :icon_search}
|
||||||
:style {:width 17
|
:style {:width 17
|
||||||
:height 17}}
|
:height 17}}
|
||||||
|
|
|
@ -1,26 +1,20 @@
|
||||||
(ns syng-im.discovery.subs
|
(ns syng-im.discovery.subs
|
||||||
(: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.models.discoveries :refer [current-tag
|
|
||||||
current-tag-updated?]]))
|
|
||||||
|
|
||||||
(register-sub :get-discoveries-by-tag
|
(register-sub :get-discoveries-by-tag
|
||||||
(fn [db [_ tag limit]]
|
(fn [db [_ tag limit]]
|
||||||
(let [discoveries (reaction (:discoveries @db))]
|
(let [discoveries (reaction (:discoveries @db))
|
||||||
|
tag' (or tag (:current-tag @db))
|
||||||
|
filter-tag (filter #(some #{tag'} (map :name (:tags %))))
|
||||||
|
xform (if limit
|
||||||
|
(comp filter-tag (take limit))
|
||||||
|
filter-tag)]
|
||||||
(->> @discoveries
|
(->> @discoveries
|
||||||
(into [] (comp (filter #(some #{tag} (map :name (:tags %))))
|
(into [] xform)
|
||||||
(take limit)))
|
|
||||||
(reaction)))))
|
(reaction)))))
|
||||||
|
|
||||||
(register-sub :get-popular-tags
|
(register-sub :get-popular-tags
|
||||||
(fn [db [_ limit]]
|
(fn [db [_ limit]]
|
||||||
(reaction (take limit (:tags @db)))))
|
(reaction (take limit (:tags @db)))))
|
||||||
|
|
||||||
(register-sub :get-current-tag
|
|
||||||
(fn [db _]
|
|
||||||
(let [current-tag-updated (-> (current-tag-updated? @db)
|
|
||||||
(reaction))]
|
|
||||||
(reaction
|
|
||||||
(let [_ @current-tag-updated]
|
|
||||||
(current-tag @db))))))
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
(ns syng-im.discovery.tag
|
||||||
|
(:require
|
||||||
|
[re-frame.core :refer [subscribe dispatch]]
|
||||||
|
[syng-im.utils.logging :as log]
|
||||||
|
[syng-im.utils.listview :refer [to-datasource2]]
|
||||||
|
[syng-im.components.react :refer [view text list-view list-item]]
|
||||||
|
[syng-im.components.toolbar :refer [toolbar]]
|
||||||
|
[syng-im.discovery.views.popular-list-item :refer [popular-list-item]]
|
||||||
|
[syng-im.discovery.styles :as st]))
|
||||||
|
|
||||||
|
(defn render-row [row _ _]
|
||||||
|
(list-item [popular-list-item row]))
|
||||||
|
|
||||||
|
(defn render-separator [_ row-id _]
|
||||||
|
(list-item [view {:style st/row-separator
|
||||||
|
:key row-id}]))
|
||||||
|
|
||||||
|
(defn title-content [tag]
|
||||||
|
[view st/tag-title-container
|
||||||
|
[text {:style st/tag-title} (str " #" tag)]])
|
||||||
|
|
||||||
|
(defn discovery-tag []
|
||||||
|
(let [tag (subscribe [:get :current-tag])
|
||||||
|
discoveries (subscribe [:get-discoveries-by-tag])]
|
||||||
|
(log/debug "Got discoveries: " @discoveries)
|
||||||
|
(fn []
|
||||||
|
(let [items @discoveries
|
||||||
|
datasource (to-datasource2 items)]
|
||||||
|
[view st/discovery-tag-container
|
||||||
|
[toolbar {:nav-action {:image {:source {:uri :icon_back}
|
||||||
|
:style st/icon-back}
|
||||||
|
:handler #(dispatch [:navigate-back])}
|
||||||
|
:title "Add Participants"
|
||||||
|
:content (title-content @tag)
|
||||||
|
:action {:image {:source {:uri :icon_search}
|
||||||
|
:style st/icon-search}
|
||||||
|
:handler (fn [])}}]
|
||||||
|
|
||||||
|
[list-view {:dataSource datasource
|
||||||
|
:renderRow render-row
|
||||||
|
:renderSeparator render-separator
|
||||||
|
:style st/recent-list}]]))))
|
|
@ -6,7 +6,7 @@
|
||||||
text]]
|
text]]
|
||||||
[syng-im.components.carousel.carousel :refer [carousel]]
|
[syng-im.components.carousel.carousel :refer [carousel]]
|
||||||
[syng-im.discovery.styles :as st]
|
[syng-im.discovery.styles :as st]
|
||||||
[syng-im.discovery.discovery-popular-list :refer [discovery-popular-list]]))
|
[syng-im.discovery.views.popular-list :refer [discovery-popular-list]]))
|
||||||
|
|
||||||
(defn page-width []
|
(defn page-width []
|
||||||
(.-width (.get (.. js/React -Dimensions) "window")))
|
(.-width (.get (.. js/React -Dimensions) "window")))
|
||||||
|
|
|
@ -1,27 +1,21 @@
|
||||||
(ns syng-im.discovery.discovery-popular-list
|
(ns syng-im.discovery.views.popular-list
|
||||||
(:require
|
(:require
|
||||||
[re-frame.core :refer [subscribe dispatch dispatch-sync]]
|
[re-frame.core :refer [subscribe dispatch]]
|
||||||
[syng-im.utils.logging :as log]
|
[syng-im.components.react :refer [view
|
||||||
[syng-im.components.react :refer [android?
|
|
||||||
view
|
|
||||||
list-view
|
list-view
|
||||||
list-item
|
list-item
|
||||||
touchable-highlight
|
touchable-highlight
|
||||||
text
|
text]]
|
||||||
image]]
|
|
||||||
[reagent.core :as r]
|
|
||||||
[syng-im.discovery.styles :as st]
|
[syng-im.discovery.styles :as st]
|
||||||
[syng-im.utils.listview :refer [to-realm-datasource to-datasource2]]
|
[syng-im.utils.listview :refer [to-datasource2]]
|
||||||
[syng-im.discovery.discovery-popular-list-item :refer [discovery-popular-list-item] ])
|
[syng-im.discovery.views.popular-list-item :refer [popular-list-item]]))
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
(defn render-row [row _ _]
|
(defn render-row [row _ _]
|
||||||
(list-item [discovery-popular-list-item row]))
|
(list-item [popular-list-item row]))
|
||||||
|
|
||||||
(defn render-separator [sectionID rowID adjacentRowHighlighted]
|
(defn render-separator [_ row-id _]
|
||||||
(list-item [view {:style st/row-separator
|
(list-item [view {:style st/row-separator
|
||||||
:key rowID}]))
|
:key row-id}]))
|
||||||
|
|
||||||
(defn discovery-popular-list [tag count]
|
(defn discovery-popular-list [tag count]
|
||||||
(let [discoveries (subscribe [:get-discoveries-by-tag tag 3])]
|
(let [discoveries (subscribe [:get-discoveries-by-tag tag 3])]
|
|
@ -1,9 +1,10 @@
|
||||||
(ns syng-im.discovery.discovery-popular-list-item
|
(ns syng-im.discovery.views.popular-list-item
|
||||||
|
;syng-im.discovery.views.popular-list-item
|
||||||
(:require [syng-im.components.react :refer [view text image]]
|
(:require [syng-im.components.react :refer [view text image]]
|
||||||
[syng-im.discovery.styles :as st]
|
[syng-im.discovery.styles :as st]
|
||||||
[reagent.core :as r]))
|
[reagent.core :as r]))
|
||||||
|
|
||||||
(defn discovery-popular-list-item
|
(defn popular-list-item
|
||||||
[{:keys [name status]}]
|
[{:keys [name status]}]
|
||||||
[view st/popular-list-item
|
[view st/popular-list-item
|
||||||
[view st/popular-list-item-name-container
|
[view st/popular-list-item-name-container
|
|
@ -1,14 +1,14 @@
|
||||||
(ns syng-im.discovery.discovery-recent
|
(ns syng-im.discovery.views.recent
|
||||||
(:require
|
(:require
|
||||||
[re-frame.core :refer [subscribe]]
|
[re-frame.core :refer [subscribe]]
|
||||||
[syng-im.components.react :refer [view list-view list-item]]
|
[syng-im.components.react :refer [view list-view list-item]]
|
||||||
[syng-im.utils.listview :refer [to-realm-datasource to-datasource2]]
|
[syng-im.utils.listview :refer [to-realm-datasource to-datasource2]]
|
||||||
[syng-im.discovery.styles :as st]
|
[syng-im.discovery.styles :as st]
|
||||||
[syng-im.discovery.discovery-popular-list-item
|
[syng-im.discovery.views.popular-list-item
|
||||||
:refer [discovery-popular-list-item]]))
|
:refer [popular-list-item]]))
|
||||||
|
|
||||||
(defn render-row [row _ _]
|
(defn render-row [row _ _]
|
||||||
(list-item [discovery-popular-list-item row]))
|
(list-item [popular-list-item row]))
|
||||||
|
|
||||||
(defn render-separator [_ row-id _]
|
(defn render-separator [_ row-id _]
|
||||||
(list-item [view {:style st/row-separator
|
(list-item [view {:style st/row-separator
|
|
@ -1,12 +1,9 @@
|
||||||
(ns syng-im.models.commands
|
(ns syng-im.models.commands
|
||||||
(:require [clojure.string :refer [join split]]
|
(:require [clojure.string :refer [join split]]
|
||||||
[clojure.walk :refer [stringify-keys keywordize-keys]]
|
[clojure.walk :refer [stringify-keys keywordize-keys]]
|
||||||
[cljs.core.async :as async :refer [chan put! <! >!]]
|
[re-frame.core :refer [subscribe dispatch]]
|
||||||
[re-frame.core :refer [subscribe dispatch dispatch-sync]]
|
|
||||||
[syng-im.db :as db]
|
[syng-im.db :as db]
|
||||||
[syng-im.components.styles :refer [color-blue
|
[syng-im.components.styles :refer [color-blue color-dark-mint]]))
|
||||||
color-dark-mint]]
|
|
||||||
[syng-im.utils.utils :refer [log toast]]))
|
|
||||||
|
|
||||||
;; todo delete
|
;; todo delete
|
||||||
(def commands [{:command :money
|
(def commands [{:command :money
|
||||||
|
|
|
@ -5,15 +5,6 @@
|
||||||
[syng-im.persistence.realm :as r]
|
[syng-im.persistence.realm :as r]
|
||||||
[syng-im.db :as db]))
|
[syng-im.db :as db]))
|
||||||
|
|
||||||
(defn current-tag-updated? [db]
|
|
||||||
(get-in db db/updated-current-tag-signal-path))
|
|
||||||
|
|
||||||
(defn current-tag [db]
|
|
||||||
(get-in db db/current-tag-path))
|
|
||||||
|
|
||||||
(defn set-current-tag [db tag]
|
|
||||||
(assoc-in db db/current-tag-path tag))
|
|
||||||
|
|
||||||
(defn get-tag [tag]
|
(defn get-tag [tag]
|
||||||
(log/debug "Getting tag: " tag)
|
(log/debug "Getting tag: " tag)
|
||||||
(-> (r/get-by-field :tag :name tag)
|
(-> (r/get-by-field :tag :name tag)
|
||||||
|
|
Loading…
Reference in New Issue