linked discovery search to status change for testing and updated react-native

Former-commit-id: ca656906c1
This commit is contained in:
Adrian Tiberius 2016-04-28 01:03:24 +03:00
parent 66b1495e2d
commit 500645e0aa
8 changed files with 43 additions and 16 deletions

View File

@ -13,10 +13,14 @@
"react-native-action-button",
"react-native-vector-icons/Ionicons",
"react-native-circle-checkbox",
"react-native-randombytes",
"react-native-randombytes"
],
"imageDirs": [
"images"
],
"iosHost": "localhost"
"iosHost": "localhost",
"envRoots": {
"dev": "env/dev",
"prod": "env/prod"
}
}

View File

@ -11,7 +11,7 @@
(figwheel/watch-and-reload
:websocket-url "ws://10.0.3.2:3449/figwheel-ws"
:heads-up-display true
:heads-up-display false
:jsload-callback #(swap! cnt inc))
(core/init)

View File

@ -168,7 +168,7 @@ function compileWarningsToYellowBox() {
if (compileWarningRx.test(msg)) {
console.warn(msg);
} else {
log.call(window.console, msg);
log.apply(window.console, arguments);
}
};
}

View File

@ -7,7 +7,8 @@
},
"dependencies": {
"awesome-phonenumber": "^1.0.12",
"react-native": "^0.22.0",
"react": "^0.14.5",
"react-native": "^0.24.1",
"react-native-action-button": "^1.1.3",
"react-native-circle-checkbox": "^0.1.3",
"react-native-contacts": "^0.2.1",

View File

@ -17,6 +17,12 @@
(def search-input (atom {:search "x"}))
(defn get-hashtags [status]
(let [hashtags (map #(subs % 1) (re-seq #"#[^ !?,;:.]+" status))]
(if hashtags
hashtags
[])))
(defn discovery [{:keys [navigator]}]
(let [showSearch (r/atom false)]
(fn []
@ -50,7 +56,7 @@
(reset! showSearch true)))}
(if @showSearch
[text-input {:underlineColorAndroid "transparent"
:value (:search @search-input)
;:value (:search @search-input)
:style {:flex 1
:marginLeft 18
:lineHeight 42
@ -61,12 +67,11 @@
:placeholder "Type your search tags here"
:onChangeText (fn [new-text]
(let [old-text (:search @search-input)]
(log (str new-text "-" old-text))
(if (not (= new-text old-text))
(swap! search-input assoc :search new-text))
))
(log (str new-text "-" old-text))))
:onSubmitEditing (fn [e]
(log (aget e "nativeEvent" "text")))}]
(let [search (aget e "nativeEvent" "text")
hashtags (get-hashtags search)]
(dispatch [:broadcast-status search hashtags])))}]
[text "Discover"])]
[scroll-view {:style {}}

View File

@ -12,6 +12,7 @@
:command nil}
:chats {}
:chats-updated-signal 0
:name "My Name"
:new-group #{}})

View File

@ -1,5 +1,7 @@
(ns syng-im.handlers.discovery
(:require [re-frame.core :refer [register-handler after dispatch]]
[syng-im.utils.debug :refer [log]]
[syng-im.protocol.api :as api]
[syng-im.models.discoveries :refer [save-discoveries
discovery-list
signal-discovery-updated
@ -10,7 +12,8 @@
(register-handler :discovery-response-received
(fn [db [_ from payload]]
(let [{:keys [status hashtags location]} payload]
(let [{:keys [status hashtags location]} payload
location (if location location "")]
(save-discoveries [{:name from
:status status
:whisper-id from
@ -18,8 +21,18 @@
:location location
:tags hashtags
:last-updated (js/Date.)}])
)))
(signal-discovery-updated db)
db)))
(register-handler :updated-discoveries
(fn [db _]
(signal-discovery-updated db)))
(signal-discovery-updated db)
db))
(register-handler :broadcast-status
(fn [db [action status hashtags]]
(let [_ (log "Status: " status)
_ (log "Hashtags: " hashtags)
name (:name db)]
(api/broadcast-discover-status name status hashtags)
db)))

View File

@ -35,7 +35,8 @@
(def fake-discoveries (generate-discoveries 20))
(defn- get-discoveries []
( let [list (realm/get-list :discoveries)]
(let [list (realm/get-list :discoveries)
_ (log list)]
(if (> (.-length list) 0) (.slice list 0) [])))
(defn load-syng-discoveries [db]
@ -118,7 +119,9 @@
(defn- add-discoveries [discoveries]
(realm/write (fn []
(let [db-discoveries (get-discoveries)]
(let [db-discoveries (.slice (discovery-list) 0)
_ (log discoveries)
_ (log (.slice db-discoveries 0))]
(dorun (map (fn [discovery]
(if (not (discovery-exist? db-discoveries discovery))
(create-discovery discovery)