mirror of
https://github.com/status-im/status-mobile.git
synced 2025-01-14 10:46:21 +00:00
linked discovery search to status change for testing and updated react-native
This commit is contained in:
parent
0c88c0556e
commit
ca656906c1
@ -13,10 +13,14 @@
|
|||||||
"react-native-action-button",
|
"react-native-action-button",
|
||||||
"react-native-vector-icons/Ionicons",
|
"react-native-vector-icons/Ionicons",
|
||||||
"react-native-circle-checkbox",
|
"react-native-circle-checkbox",
|
||||||
"react-native-randombytes",
|
"react-native-randombytes"
|
||||||
],
|
],
|
||||||
"imageDirs": [
|
"imageDirs": [
|
||||||
"images"
|
"images"
|
||||||
],
|
],
|
||||||
"iosHost": "localhost"
|
"iosHost": "localhost",
|
||||||
|
"envRoots": {
|
||||||
|
"dev": "env/dev",
|
||||||
|
"prod": "env/prod"
|
||||||
|
}
|
||||||
}
|
}
|
2
env/dev/env/android/main.cljs
vendored
2
env/dev/env/android/main.cljs
vendored
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
(figwheel/watch-and-reload
|
(figwheel/watch-and-reload
|
||||||
:websocket-url "ws://10.0.3.2:3449/figwheel-ws"
|
:websocket-url "ws://10.0.3.2:3449/figwheel-ws"
|
||||||
:heads-up-display true
|
:heads-up-display false
|
||||||
:jsload-callback #(swap! cnt inc))
|
:jsload-callback #(swap! cnt inc))
|
||||||
|
|
||||||
(core/init)
|
(core/init)
|
@ -168,7 +168,7 @@ function compileWarningsToYellowBox() {
|
|||||||
if (compileWarningRx.test(msg)) {
|
if (compileWarningRx.test(msg)) {
|
||||||
console.warn(msg);
|
console.warn(msg);
|
||||||
} else {
|
} else {
|
||||||
log.call(window.console, msg);
|
log.apply(window.console, arguments);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,8 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"awesome-phonenumber": "^1.0.12",
|
"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-action-button": "^1.1.3",
|
||||||
"react-native-circle-checkbox": "^0.1.3",
|
"react-native-circle-checkbox": "^0.1.3",
|
||||||
"react-native-contacts": "^0.2.1",
|
"react-native-contacts": "^0.2.1",
|
||||||
|
@ -17,6 +17,12 @@
|
|||||||
|
|
||||||
(def search-input (atom {:search "x"}))
|
(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]}]
|
(defn discovery [{:keys [navigator]}]
|
||||||
(let [showSearch (r/atom false)]
|
(let [showSearch (r/atom false)]
|
||||||
(fn []
|
(fn []
|
||||||
@ -50,7 +56,7 @@
|
|||||||
(reset! showSearch true)))}
|
(reset! showSearch true)))}
|
||||||
(if @showSearch
|
(if @showSearch
|
||||||
[text-input {:underlineColorAndroid "transparent"
|
[text-input {:underlineColorAndroid "transparent"
|
||||||
:value (:search @search-input)
|
;:value (:search @search-input)
|
||||||
:style {:flex 1
|
:style {:flex 1
|
||||||
:marginLeft 18
|
:marginLeft 18
|
||||||
:lineHeight 42
|
:lineHeight 42
|
||||||
@ -61,12 +67,11 @@
|
|||||||
: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 (str new-text "-" old-text))))
|
||||||
(if (not (= new-text old-text))
|
|
||||||
(swap! search-input assoc :search new-text))
|
|
||||||
))
|
|
||||||
:onSubmitEditing (fn [e]
|
: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"])]
|
[text "Discover"])]
|
||||||
|
|
||||||
[scroll-view {:style {}}
|
[scroll-view {:style {}}
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
:command nil}
|
:command nil}
|
||||||
:chats {}
|
:chats {}
|
||||||
:chats-updated-signal 0
|
:chats-updated-signal 0
|
||||||
|
:name "My Name"
|
||||||
:new-group #{}})
|
:new-group #{}})
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
(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.protocol.api :as api]
|
||||||
[syng-im.models.discoveries :refer [save-discoveries
|
[syng-im.models.discoveries :refer [save-discoveries
|
||||||
discovery-list
|
discovery-list
|
||||||
signal-discovery-updated
|
signal-discovery-updated
|
||||||
@ -10,7 +12,8 @@
|
|||||||
|
|
||||||
(register-handler :discovery-response-received
|
(register-handler :discovery-response-received
|
||||||
(fn [db [_ from payload]]
|
(fn [db [_ from payload]]
|
||||||
(let [{:keys [status hashtags location]} payload]
|
(let [{:keys [status hashtags location]} payload
|
||||||
|
location (if location location "")]
|
||||||
(save-discoveries [{:name from
|
(save-discoveries [{:name from
|
||||||
:status status
|
:status status
|
||||||
:whisper-id from
|
:whisper-id from
|
||||||
@ -18,8 +21,18 @@
|
|||||||
:location location
|
:location location
|
||||||
:tags hashtags
|
:tags hashtags
|
||||||
:last-updated (js/Date.)}])
|
:last-updated (js/Date.)}])
|
||||||
)))
|
(signal-discovery-updated db)
|
||||||
|
db)))
|
||||||
|
|
||||||
(register-handler :updated-discoveries
|
(register-handler :updated-discoveries
|
||||||
(fn [db _]
|
(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)))
|
@ -35,7 +35,8 @@
|
|||||||
(def fake-discoveries (generate-discoveries 20))
|
(def fake-discoveries (generate-discoveries 20))
|
||||||
|
|
||||||
(defn- get-discoveries []
|
(defn- get-discoveries []
|
||||||
( let [list (realm/get-list :discoveries)]
|
(let [list (realm/get-list :discoveries)
|
||||||
|
_ (log list)]
|
||||||
(if (> (.-length list) 0) (.slice list 0) [])))
|
(if (> (.-length list) 0) (.slice list 0) [])))
|
||||||
|
|
||||||
(defn load-syng-discoveries [db]
|
(defn load-syng-discoveries [db]
|
||||||
@ -118,7 +119,9 @@
|
|||||||
|
|
||||||
(defn- add-discoveries [discoveries]
|
(defn- add-discoveries [discoveries]
|
||||||
(realm/write (fn []
|
(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]
|
(dorun (map (fn [discovery]
|
||||||
(if (not (discovery-exist? db-discoveries discovery))
|
(if (not (discovery-exist? db-discoveries discovery))
|
||||||
(create-discovery discovery)
|
(create-discovery discovery)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user