handle group chat invite acks

This commit is contained in:
michaelr 2016-04-07 14:01:41 +03:00
parent ee54e12f5a
commit ad4401a42e
5 changed files with 48 additions and 29 deletions

View File

@ -25,9 +25,12 @@
(into {})))
(defn add-msg-color [{:keys [from] :as msg} contact-by-identity]
(if (= "system" from)
(assoc msg :text-color "#4A5258"
:background-color "#D3EEEF")
(let [{:keys [text-color background-color]} (get contact-by-identity from)]
(assoc msg :text-color text-color
:background-color background-color)))
:background-color background-color))))
(defn chat [{:keys [navigator]}]
(let [messages (subscribe [:get-chat-messages])

View File

@ -86,7 +86,6 @@
content)]]))
(defn message-content [{:keys [content-type content outgoing text-color background-color]}]
(let [_ (log/debug color)]
[view {:style (merge {:borderRadius 6}
(if (= content-type text-content-type)
{:paddingVertical 12
@ -107,7 +106,7 @@
(= content-type content-type-command)
[message-content-command content]
:else [message-content-audio {:content content
:content-type content-type}])]))
:content-type content-type}])])
(defn message-delivery-status [{:keys [delivery-status]}]
[view {:style {:flexDirection "row"

View File

@ -110,6 +110,19 @@
(save-message chat-id msg)
(signal-chat-updated db chat-id)))
(defn joined-chat-msg [chat-id from msg-id]
(let [contact-name (:name (contacts/contatct-by-identity from))]
(save-message chat-id {:from "system"
:msg-id msg-id
:content (str (or contact-name from) " received chat invitation")
:content-type text-content-type})))
(register-handler :group-chat-invite-acked
(fn [db [action from group-id ack-msg-id]]
(log/debug action from group-id ack-msg-id)
(joined-chat-msg group-id from ack-msg-id)
(signal-chat-updated db group-id)))
(register-handler :acked-msg
(fn [db [_ from msg-id]]
(update-message! {:msg-id msg-id

View File

@ -91,6 +91,10 @@
(-> (r/get-all :contacts)
(r/sorted :name :asc)))
(defn contatct-by-identity [identity]
(-> (r/get-by-field :contacts :whisper-identity identity)
(r/single-cljs)))
(comment
(r/write #(create-contact {:phone-number "0543072333"

View File

@ -28,8 +28,8 @@
payload :payload} event]
(dispatch [:group-received-msg (assoc payload :from from
:group-id group-id)]))
;:group-chat-invite-acked (let [{:keys [from group-id]} event]
; (add-to-chat "group-chat" ":" (str "Received ACK for group chat invitation from " from " for group-id: " group-id)))
:group-chat-invite-acked (let [{:keys [from group-id ack-msg-id]} event]
(dispatch [:group-chat-invite-acked from group-id ack-msg-id]))
;:group-new-participant (let [{:keys [group-id identity from]} event]
; (add-to-chat "group-chat" ":" (str (shorten from) " added " (shorten identity) " to group chat"))
; (add-identity-to-group-list identity))