improved system messages for edge cases

This commit is contained in:
michaelr 2016-04-29 16:24:03 +03:00
parent 8f04104cc0
commit a555c57bcc
2 changed files with 87 additions and 83 deletions

View File

@ -156,7 +156,9 @@
(defn participant-invited-to-group-msg [chat-id identity from msg-id] (defn participant-invited-to-group-msg [chat-id identity from msg-id]
(let [inviter-name (:name (contacts/contact-by-identity from)) (let [inviter-name (:name (contacts/contact-by-identity from))
invitee-name (:name (contacts/contact-by-identity identity))] invitee-name (if (= identity (api/my-identity))
"You"
(:name (contacts/contact-by-identity identity)))]
(save-message chat-id {:from "system" (save-message chat-id {:from "system"
:msg-id msg-id :msg-id msg-id
:content (str (or inviter-name from) " invited " (or invitee-name identity)) :content (str (or inviter-name from) " invited " (or invitee-name identity))
@ -220,8 +222,10 @@
(register-handler :participant-left-group (register-handler :participant-left-group
(fn [db [action from group-id msg-id]] (fn [db [action from group-id msg-id]]
(log/debug action msg-id from group-id) (log/debug action msg-id from group-id)
(participant-left-group-msg group-id from msg-id) (if (= (api/my-identity) from)
(signal-chat-updated db group-id))) db
(do (participant-left-group-msg group-id from msg-id)
(signal-chat-updated db group-id)))))
(register-handler :participant-invited-to-group (register-handler :participant-invited-to-group
(fn [db [action from group-id identity msg-id]] (fn [db [action from group-id identity msg-id]]

View File

@ -140,7 +140,7 @@
(-> (aget (aget (chats-list) 0) "contacts") (-> (aget (aget (chats-list) 0) "contacts")
(r/cljs-list)) (r/cljs-list))
(r/delete (chats-list)) (r/write (fn [] (r/delete (chats-list))))
(swap! re-frame.db/app-db signal-chats-updated) (swap! re-frame.db/app-db signal-chats-updated)