Merge branch 'feature/#123' into feature/command-suggestions-animation

This commit is contained in:
Roman Volosovskyi 2016-06-27 16:21:29 +03:00
commit fa90b9efd3
5 changed files with 54 additions and 34 deletions

View File

@ -84,6 +84,10 @@ public class GethService extends Service {
}).start(); }).start();
} }
public void signalEvent(String jsonEvent) {
}
@Nullable @Nullable
@Override @Override
public IBinder onBind(Intent intent) { public IBinder onBind(Intent intent) {

View File

@ -48,6 +48,7 @@
(.addOrientationListener (.addOrientationListener
orientation orientation
#(dispatch [:set :orientation (orientation->keyword %)])) #(dispatch [:set :orientation (orientation->keyword %)]))
(.lockToPortrait orientation)
(.addListener device-event-emitter (.addListener device-event-emitter
"keyboardDidShow" "keyboardDidShow"
(fn [e] (fn [e]

View File

@ -27,13 +27,12 @@
(assoc db :show-actions show-actions))) (assoc db :show-actions show-actions)))
(register-handler :load-more-messages (register-handler :load-more-messages
(fn [db _] debug
db (fn [{:keys [current-chat-id] :as db} _]
;; TODO implement (let [messages-path [:chats current-chat-id :messages]
#_(let [chat-id (get-in db [:chat :current-chat-id]) messages (get-in db messages-path)
messages [:chats chat-id :messages] new-messages (messages/get-messages current-chat-id (count messages))]
new-messages (gen-messages 10)] (update-in db messages-path concat new-messages))))
(update-in db messages concat new-messages))))
(defn safe-trim [s] (defn safe-trim [s]
(when (string? s) (when (string? s)
@ -47,10 +46,10 @@
(defn invoke-suggestions-handler! (defn invoke-suggestions-handler!
[{:keys [current-chat-id] :as db} _] [{:keys [current-chat-id] :as db} _]
(let [commands (get-in db [:chats current-chat-id :commands]) (let [{:keys [command content]} (get-in db [:chats current-chat-id :command-input])
{:keys [command content]} (get-in db [:chats current-chat-id :command-input]) {:keys [name type]} command
path [(if (commands command) :commands :responses) path [(if (= :command type) :commands :responses)
(:name command) name
:params :params
0 0
:suggestions] :suggestions]
@ -79,11 +78,11 @@
(assoc-in db [:chats current-chat-id :input-text] text)) (assoc-in db [:chats current-chat-id :input-text] text))
(defn invoke-command-preview! (defn invoke-command-preview!
[{:keys [current-chat-id staged-command] :as db} _] [{:keys [current-chat-id staged-command]} _]
(let [commands (get-in db [:chats current-chat-id :commands]) (let [{:keys [command content]} staged-command
{:keys [command content]} staged-command {:keys [name type]} command
path [(if (commands command) :commands :responses) path [(if (= :command type) :commands :responses)
(:name command) name
:preview] :preview]
params {:value content}] params {:value content}]
(j/call current-chat-id (j/call current-chat-id
@ -272,18 +271,18 @@
(dissoc new-command :rendered-preview)))) (dissoc new-command :rendered-preview))))
(defn invoke-commands-handlers! (defn invoke-commands-handlers!
[{:keys [new-commands current-chat-id] :as db}] [{:keys [new-commands current-chat-id]}]
(let [commands (get-in db [:chats current-chat-id :commands])] (doseq [{:keys [content] :as com} new-commands]
(doseq [{:keys [content] :as com} new-commands] (let [{:keys [command content]} content
(let [{:keys [command content]} content type (:type command)
path [(if (commands command) :commands :responses) path [(if (= :command type) :commands :responses)
command command
:handler] :handler]
params {:value content}] params {:value content}]
(j/call current-chat-id (j/call current-chat-id
path path
params params
#(dispatch [:command-handler! com %])))))) #(dispatch [:command-handler! com %])))))
(defn handle-commands (defn handle-commands
[{:keys [new-commands]}] [{:keys [new-commands]}]
@ -349,10 +348,8 @@
(defn load-messages! (defn load-messages!
([db] (load-messages! db nil)) ([db] (load-messages! db nil))
([db _] ([{:keys [current-chat-id] :as db} _]
(->> (:current-chat-id db) (assoc db :messages (messages/get-messages current-chat-id))))
messages/get-messages
(assoc db :messages))))
(defn init-chat (defn init-chat
([db] (init-chat db nil)) ([db] (init-chat db nil))
@ -374,7 +371,7 @@
(map (fn [{:keys [chat-id] :as chat}] (map (fn [{:keys [chat-id] :as chat}]
[chat-id chat])) [chat-id chat]))
(into {})) (into {}))
ids (set (keys chats))] ids (set (keys chats))]
(-> db (-> db
(assoc :chats chats) (assoc :chats chats)
(assoc :chats-ids ids) (assoc :chats-ids ids)

View File

@ -2,7 +2,7 @@
(def ethereum-rpc-url "http://localhost:8545") (def ethereum-rpc-url "http://localhost:8545")
(def server-address "http://rpc0.status.im:20000/") (def server-address "http://api.status.im/")
;; (def server-address "http://10.0.3.2:3000/") ;; (def server-address "http://10.0.3.2:3000/")
;; (def server-address "http://localhost:3000/") ;; (def server-address "http://localhost:3000/")
@ -15,3 +15,5 @@
(def response-input-hiding-duration 100) (def response-input-hiding-duration 100)
(def response-suggesstion-resize-duration 100) (def response-suggesstion-resize-duration 100)
(def default-number-of-messages 10)

View File

@ -47,6 +47,7 @@
#{c/content-type-command c/content-type-command-request} #{c/content-type-command c/content-type-command-request}
type)) type))
<<<<<<< HEAD
(defn get-messages [chat-id] (defn get-messages [chat-id]
(->> (-> (r/get-by-field :msgs :chat-id chat-id) (->> (-> (r/get-by-field :msgs :chat-id chat-id)
(r/sorted :timestamp :desc) (r/sorted :timestamp :desc)
@ -63,6 +64,21 @@
(read-string preview)))) (read-string preview))))
(dissoc :preview)) (dissoc :preview))
message))))) message)))))
=======
(defn get-messages
([chat-id] (get-messages chat-id 0))
([chat-id from]
(->> (-> (r/get-by-field :msgs :chat-id chat-id)
(r/sorted :timestamp :desc)
(r/page from (+ from c/default-number-of-messages))
(r/collection->map))
(into '())
reverse
(map (fn [{:keys [content-type] :as message}]
(if (command-type? content-type)
(update message :content str-to-map)
message))))))
>>>>>>> develop
(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)