parent
97b97ec13f
commit
c1144e1d68
|
@ -25,9 +25,12 @@
|
|||
(into {})))
|
||||
|
||||
(defn add-msg-color [{:keys [from] :as msg} contact-by-identity]
|
||||
(let [{:keys [text-color background-color]} (get contact-by-identity from)]
|
||||
(assoc msg :text-color text-color
|
||||
:background-color background-color)))
|
||||
(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))))
|
||||
|
||||
(defn chat [{:keys [navigator]}]
|
||||
(let [messages (subscribe [:get-chat-messages])
|
||||
|
|
|
@ -86,28 +86,27 @@
|
|||
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
|
||||
:paddingHorizontal 16}
|
||||
{:paddingVertical 14
|
||||
:paddingHorizontal 10})
|
||||
(if outgoing
|
||||
{:backgroundColor "#D3EEEF"}
|
||||
{:backgroundColor background-color}))}
|
||||
(cond
|
||||
(= content-type text-content-type)
|
||||
[text {:style (merge {:fontSize 14
|
||||
:fontFamily "Avenir-Roman"}
|
||||
(if outgoing
|
||||
{:color "#4A5258"}
|
||||
{:color text-color}))}
|
||||
content]
|
||||
(= content-type content-type-command)
|
||||
[message-content-command content]
|
||||
:else [message-content-audio {:content content
|
||||
:content-type content-type}])]))
|
||||
[view {:style (merge {:borderRadius 6}
|
||||
(if (= content-type text-content-type)
|
||||
{:paddingVertical 12
|
||||
:paddingHorizontal 16}
|
||||
{:paddingVertical 14
|
||||
:paddingHorizontal 10})
|
||||
(if outgoing
|
||||
{:backgroundColor "#D3EEEF"}
|
||||
{:backgroundColor background-color}))}
|
||||
(cond
|
||||
(= content-type text-content-type)
|
||||
[text {:style (merge {:fontSize 14
|
||||
:fontFamily "Avenir-Roman"}
|
||||
(if outgoing
|
||||
{:color "#4A5258"}
|
||||
{:color text-color}))}
|
||||
content]
|
||||
(= content-type content-type-command)
|
||||
[message-content-command content]
|
||||
:else [message-content-audio {:content content
|
||||
:content-type content-type}])])
|
||||
|
||||
(defn message-delivery-status [{:keys [delivery-status]}]
|
||||
[view {:style {:flexDirection "row"
|
||||
|
|
|
@ -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
|
||||
|
@ -128,7 +141,7 @@
|
|||
(log/debug action "chat-id" chat-id "text" text)
|
||||
(let [msg (if (= chat-id "console")
|
||||
(sign-up-service/send-console-msg text)
|
||||
(let [{msg-id :msg-id
|
||||
(let [{msg-id :msg-id
|
||||
{from :from
|
||||
to :to} :msg} (api/send-user-msg {:to chat-id
|
||||
:content text})]
|
||||
|
@ -147,7 +160,7 @@
|
|||
(let [msg (if (= chat-id "console")
|
||||
(sign-up-service/send-console-command command content)
|
||||
;; TODO handle command, now sends as plain message
|
||||
(let [{msg-id :msg-id
|
||||
(let [{msg-id :msg-id
|
||||
{from :from
|
||||
to :to} :msg} (api/send-user-msg {:to chat-id
|
||||
:content content})]
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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))
|
||||
|
|
Loading…
Reference in New Issue