"seen" message

Former-commit-id: 155626f59a
This commit is contained in:
Roman Volosovskyi 2016-07-06 11:55:21 +03:00
parent 4a70678ced
commit 34059e5c61
6 changed files with 48 additions and 18 deletions

View File

@ -213,7 +213,7 @@ public class GethService extends Service {
String address = data.getString("address"); String address = data.getString("address");
String password = data.getString("password"); String password = data.getString("password");
// TODO: remove third argument // TODO: remove third argument
String result = Statusgo.Login(address, password); String result = Statusgo.UnlockAccount(address, password, 0);
Log.d(TAG, "Unlocked account: " + result); Log.d(TAG, "Unlocked account: " + result);
Bundle replyData = new Bundle(); Bundle replyData = new Bundle();

View File

@ -10,7 +10,7 @@
[prismatic/schema "1.0.4"] [prismatic/schema "1.0.4"]
^{:voom {:repo "git@github.com:status-im/status-lib.git" ^{:voom {:repo "git@github.com:status-im/status-lib.git"
:branch "master"}} :branch "master"}}
[status-im/protocol "0.1.1-20160705_154931-g96b5c92"] [status-im/protocol "0.1.1-20160706_085008-ge61756a"]
[natal-shell "0.1.6"] [natal-shell "0.1.6"]
[com.andrewmcveigh/cljs-time "0.4.0"]] [com.andrewmcveigh/cljs-time "0.4.0"]]
:plugins [[lein-cljsbuild "1.1.1"] :plugins [[lein-cljsbuild "1.1.1"]

View File

@ -571,3 +571,11 @@
(dispatch [:fix-commands-suggestions-height])))))] (dispatch [:fix-commands-suggestions-height])))))]
(fn [db [_ h]] (fn [db [_ h]]
(assoc db :layout-height h))) (assoc db :layout-height h)))
(register-handler :send-seen!
#_(afetr (fn [_ [_ chat-id message-id]]
(dispatch [:msg-seen chat-id message-id])))
(debug (u/side-effect!
(fn [_ [_ chat-id message-id]]
(api/send-seen chat-id message-id)))))

View File

@ -124,7 +124,7 @@
[{:keys [delivery-status msg-id to] :as m}] [{:keys [delivery-status msg-id to] :as m}]
[status [:get-in [:message-status to msg-id]]] [status [:get-in [:message-status to msg-id]]]
[view st/delivery-view [view st/delivery-view
[image {:source (case delivery-status [image {:source (case (or status delivery-status)
:seen {:uri :icon_ok_small} :seen {:uri :icon_ok_small}
:seen-by-everyone {:uri :icon_ok_small} :seen-by-everyone {:uri :icon_ok_small}
:failed res/delivery-failed-icon :failed res/delivery-failed-icon
@ -205,7 +205,18 @@
(into [view] children))) (into [view] children)))
(defn chat-message (defn chat-message
[{:keys [outgoing delivery-status timestamp new-day group-chat] [{:keys [outgoing delivery-status timestamp new-day group-chat msg-id chat-id]
:as message}]
(let [status (subscribe [:get-in [:message-status chat-id msg-id]])]
(r/create-class
{:component-did-mount
(fn []
(when (and outgoing
(not= :seen delivery-status)
(not= :seen @status))
(dispatch [:send-seen! chat-id msg-id])))
:reagent-render
(fn [{:keys [outgoing delivery-status timestamp new-day group-chat]
:as message}] :as message}]
[message-container message [message-container message
;; TODO there is no new-day info in message ;; TODO there is no new-day info in message
@ -218,4 +229,4 @@
incoming-group-message-body incoming-group-message-body
message-body) message-body)
(merge message {:delivery-status (keyword delivery-status) (merge message {:delivery-status (keyword delivery-status)
:incoming-group incoming-group})])]]) :incoming-group incoming-group})])]])})))

View File

@ -109,7 +109,10 @@
(defn update-message-status [status] (defn update-message-status [status]
(fn [db [_ from msg-id]] (fn [db [_ from msg-id]]
(assoc-in db [:message-status from msg-id] status))) (let [current-status (get-in db [:message-status from msg-id])]
(if-not (= :seen current-status)
(assoc-in db [:message-status from msg-id] status)
db))))
(register-handler :acked-msg (register-handler :acked-msg
(after (update-message! :delivered)) (after (update-message! :delivered))
@ -118,3 +121,9 @@
(register-handler :msg-delivery-failed (register-handler :msg-delivery-failed
(after (update-message! :failed)) (after (update-message! :failed))
(update-message-status :failed)) (update-message-status :failed))
;; todo maybe it is fine to treat as "seen" all messages that are older
;; than current
(register-handler :msg-seen
(after (update-message! :seen))
(update-message-status :seen))

View File

@ -22,6 +22,8 @@
(dispatch [:received-msg (assoc payload :from from :to to)])) (dispatch [:received-msg (assoc payload :from from :to to)]))
:msg-acked (let [{:keys [msg-id from]} event] :msg-acked (let [{:keys [msg-id from]} event]
(dispatch [:acked-msg from msg-id])) (dispatch [:acked-msg from msg-id]))
:msg-seen (let [{:keys [msg-id from]} event]
(dispatch [:msg-seen from msg-id]))
:delivery-failed (let [{:keys [msg-id from]} event] :delivery-failed (let [{:keys [msg-id from]} event]
(dispatch [:msg-delivery-failed from msg-id])) (dispatch [:msg-delivery-failed from msg-id]))
:new-group-chat (let [{:keys [from group-id identities group-name]} event] :new-group-chat (let [{:keys [from group-id identities group-name]} event]