"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 password = data.getString("password");
// TODO: remove third argument
String result = Statusgo.Login(address, password);
String result = Statusgo.UnlockAccount(address, password, 0);
Log.d(TAG, "Unlocked account: " + result);
Bundle replyData = new Bundle();

View File

@ -10,7 +10,7 @@
[prismatic/schema "1.0.4"]
^{:voom {:repo "git@github.com:status-im/status-lib.git"
: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"]
[com.andrewmcveigh/cljs-time "0.4.0"]]
:plugins [[lein-cljsbuild "1.1.1"]

View File

@ -568,6 +568,14 @@
(let [suggestions (get-in db [:command-suggestions current-chat-id])
mode (get-in db [:edit-mode current-chat-id])]
(when (and (= :text mode)) (seq suggestions)
(dispatch [:fix-commands-suggestions-height])))))]
(dispatch [:fix-commands-suggestions-height])))))]
(fn [db [_ 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}]
[status [:get-in [:message-status to msg-id]]]
[view st/delivery-view
[image {:source (case delivery-status
[image {:source (case (or status delivery-status)
:seen {:uri :icon_ok_small}
:seen-by-everyone {:uri :icon_ok_small}
:failed res/delivery-failed-icon
@ -205,17 +205,28 @@
(into [view] children)))
(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}]
[message-container message
;; TODO there is no new-day info in message
(when new-day
[message-date timestamp])
[view
(let [incoming-group (and group-chat (not outgoing))]
[message-content
(if incoming-group
incoming-group-message-body
message-body)
(merge message {:delivery-status (keyword delivery-status)
:incoming-group incoming-group})])]])
(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}]
[message-container message
;; TODO there is no new-day info in message
(when new-day
[message-date timestamp])
[view
(let [incoming-group (and group-chat (not outgoing))]
[message-content
(if incoming-group
incoming-group-message-body
message-body)
(merge message {:delivery-status (keyword delivery-status)
:incoming-group incoming-group})])]])})))

View File

@ -109,7 +109,10 @@
(defn update-message-status [status]
(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
(after (update-message! :delivered))
@ -118,3 +121,9 @@
(register-handler :msg-delivery-failed
(after (update-message! :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)]))
:msg-acked (let [{:keys [msg-id from]} event]
(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]
(dispatch [:msg-delivery-failed from msg-id]))
:new-group-chat (let [{:keys [from group-id identities group-name]} event]