Chats list: new messages counter for group chat (fixes #252)

Former-commit-id: 3c28b83e43
This commit is contained in:
Roman Volosovskyi 2016-09-23 16:30:30 +03:00
parent 8643a1eb2a
commit 54f76720c4
3 changed files with 26 additions and 28 deletions

View File

@ -417,11 +417,8 @@
(fn [db [_ h]] (fn [db [_ h]]
(assoc db :layout-height h))) (assoc db :layout-height h)))
(register-handler :send-seen! (defn send-seen!
(after (fn [_ [_ options]] [{:keys [web3 current-public-key chats]}
(dispatch [:message-seen options])))
(u/side-effect!
(fn [{:keys [web3 current-public-key chats]}
[_ {:keys [from chat-id message-id]}]] [_ {:keys [from chat-id message-id]}]]
(when-not (console? chat-id) (when-not (console? chat-id)
(let [{:keys [group-chat]} (chats chat-id)] (let [{:keys [group-chat]} (chats chat-id)]
@ -429,7 +426,14 @@
:message {:from current-public-key :message {:from current-public-key
:to from :to from
:group-id (when group-chat chat-id) :group-id (when group-chat chat-id)
:message-id message-id}})))))) :message-id message-id}}))))
(register-handler :send-seen!
[(after (fn [_ [_ {:keys [message-id]}]]
(messages/update-message! {:message-id message-id
:message-status :seen})))
(after (fn [_ [_ {:keys [chat-id]}]]
(dispatch [:remove-unviewed-messages chat-id])))]
(u/side-effect! send-seen!))
(register-handler :set-web-view-url (register-handler :set-web-view-url
(fn [{:keys [current-chat-id] :as db} [_ url]] (fn [{:keys [current-chat-id] :as db} [_ url]]

View File

@ -41,8 +41,6 @@
(defview chats-list [] (defview chats-list []
[chats [:get :chats]] [chats [:get :chats]]
;; todo what is this?!
#_(dispatch [:set :chats-scrolled? false])
[view st/chats-container [view st/chats-container
[chats-list-toolbar] [chats-list-toolbar]
[list-view {:dataSource (to-datasource chats) [list-view {:dataSource (to-datasource chats)

View File

@ -234,11 +234,7 @@
(update-message-status :sent)) (update-message-status :sent))
(register-handler :message-seen (register-handler :message-seen
[(after (save-message-status! :seen)) [(after (save-message-status! :seen))]
(after (fn [_ [_ {:keys [from]
{:keys [group-id]} :payload}]]
(when-not group-id
(dispatch [:remove-unviewed-messages from]))))]
(update-message-status :seen)) (update-message-status :seen))
(register-handler :pending-message-upsert (register-handler :pending-message-upsert