diff --git a/.re-natal b/.re-natal index 282fd17ebb..feeb62e3c6 100644 --- a/.re-natal +++ b/.re-natal @@ -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" + } } \ No newline at end of file diff --git a/env/dev/env/android/main.cljs b/env/dev/env/android/main.cljs index 0da80188c4..f80f25c166 100644 --- a/env/dev/env/android/main.cljs +++ b/env/dev/env/android/main.cljs @@ -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) \ No newline at end of file diff --git a/figwheel-bridge.js b/figwheel-bridge.js index 6df4702339..137673ca19 100644 --- a/figwheel-bridge.js +++ b/figwheel-bridge.js @@ -168,7 +168,7 @@ function compileWarningsToYellowBox() { if (compileWarningRx.test(msg)) { console.warn(msg); } else { - log.call(window.console, msg); + log.apply(window.console, arguments); } }; } diff --git a/package.json b/package.json index f069c032a4..602cacea56 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/syng_im/components/discovery/discovery.cljs b/src/syng_im/components/discovery/discovery.cljs index f3e464b840..ab423de565 100644 --- a/src/syng_im/components/discovery/discovery.cljs +++ b/src/syng_im/components/discovery/discovery.cljs @@ -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 {}} diff --git a/src/syng_im/db.cljs b/src/syng_im/db.cljs index 741402a950..6d1eba9c58 100644 --- a/src/syng_im/db.cljs +++ b/src/syng_im/db.cljs @@ -12,6 +12,7 @@ :command nil} :chats {} :chats-updated-signal 0 + :name "My Name" :new-group #{}}) diff --git a/src/syng_im/handlers/discovery.cljs b/src/syng_im/handlers/discovery.cljs index 8820321a96..ea70f55980 100644 --- a/src/syng_im/handlers/discovery.cljs +++ b/src/syng_im/handlers/discovery.cljs @@ -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))) \ No newline at end of file + (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))) \ No newline at end of file diff --git a/src/syng_im/models/discoveries.cljs b/src/syng_im/models/discoveries.cljs index 6278f5e2e2..57bfff0126 100644 --- a/src/syng_im/models/discoveries.cljs +++ b/src/syng_im/models/discoveries.cljs @@ -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)