mirror of
https://github.com/status-im/status-react.git
synced 2025-01-24 18:00:45 +00:00
handle group chat invite acks
This commit is contained in:
parent
ee54e12f5a
commit
ad4401a42e
@ -25,9 +25,12 @@
|
|||||||
(into {})))
|
(into {})))
|
||||||
|
|
||||||
(defn add-msg-color [{:keys [from] :as msg} contact-by-identity]
|
(defn add-msg-color [{:keys [from] :as msg} contact-by-identity]
|
||||||
(let [{:keys [text-color background-color]} (get contact-by-identity from)]
|
(if (= "system" from)
|
||||||
(assoc msg :text-color text-color
|
(assoc msg :text-color "#4A5258"
|
||||||
:background-color background-color)))
|
: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]}]
|
(defn chat [{:keys [navigator]}]
|
||||||
(let [messages (subscribe [:get-chat-messages])
|
(let [messages (subscribe [:get-chat-messages])
|
||||||
|
@ -86,28 +86,27 @@
|
|||||||
content)]]))
|
content)]]))
|
||||||
|
|
||||||
(defn message-content [{:keys [content-type content outgoing text-color background-color]}]
|
(defn message-content [{:keys [content-type content outgoing text-color background-color]}]
|
||||||
(let [_ (log/debug color)]
|
[view {:style (merge {:borderRadius 6}
|
||||||
[view {:style (merge {:borderRadius 6}
|
(if (= content-type text-content-type)
|
||||||
(if (= content-type text-content-type)
|
{:paddingVertical 12
|
||||||
{:paddingVertical 12
|
:paddingHorizontal 16}
|
||||||
:paddingHorizontal 16}
|
{:paddingVertical 14
|
||||||
{:paddingVertical 14
|
:paddingHorizontal 10})
|
||||||
:paddingHorizontal 10})
|
(if outgoing
|
||||||
(if outgoing
|
{:backgroundColor "#D3EEEF"}
|
||||||
{:backgroundColor "#D3EEEF"}
|
{:backgroundColor background-color}))}
|
||||||
{:backgroundColor background-color}))}
|
(cond
|
||||||
(cond
|
(= content-type text-content-type)
|
||||||
(= content-type text-content-type)
|
[text {:style (merge {:fontSize 14
|
||||||
[text {:style (merge {:fontSize 14
|
:fontFamily "Avenir-Roman"}
|
||||||
:fontFamily "Avenir-Roman"}
|
(if outgoing
|
||||||
(if outgoing
|
{:color "#4A5258"}
|
||||||
{:color "#4A5258"}
|
{:color text-color}))}
|
||||||
{:color text-color}))}
|
content]
|
||||||
content]
|
(= content-type content-type-command)
|
||||||
(= content-type content-type-command)
|
[message-content-command content]
|
||||||
[message-content-command content]
|
:else [message-content-audio {:content content
|
||||||
:else [message-content-audio {:content content
|
:content-type content-type}])])
|
||||||
:content-type content-type}])]))
|
|
||||||
|
|
||||||
(defn message-delivery-status [{:keys [delivery-status]}]
|
(defn message-delivery-status [{:keys [delivery-status]}]
|
||||||
[view {:style {:flexDirection "row"
|
[view {:style {:flexDirection "row"
|
||||||
|
@ -110,6 +110,19 @@
|
|||||||
(save-message chat-id msg)
|
(save-message chat-id msg)
|
||||||
(signal-chat-updated db chat-id)))
|
(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
|
(register-handler :acked-msg
|
||||||
(fn [db [_ from msg-id]]
|
(fn [db [_ from msg-id]]
|
||||||
(update-message! {:msg-id msg-id
|
(update-message! {:msg-id msg-id
|
||||||
@ -128,7 +141,7 @@
|
|||||||
(log/debug action "chat-id" chat-id "text" text)
|
(log/debug action "chat-id" chat-id "text" text)
|
||||||
(let [msg (if (= chat-id "console")
|
(let [msg (if (= chat-id "console")
|
||||||
(sign-up-service/send-console-msg text)
|
(sign-up-service/send-console-msg text)
|
||||||
(let [{msg-id :msg-id
|
(let [{msg-id :msg-id
|
||||||
{from :from
|
{from :from
|
||||||
to :to} :msg} (api/send-user-msg {:to chat-id
|
to :to} :msg} (api/send-user-msg {:to chat-id
|
||||||
:content text})]
|
:content text})]
|
||||||
@ -147,7 +160,7 @@
|
|||||||
(let [msg (if (= chat-id "console")
|
(let [msg (if (= chat-id "console")
|
||||||
(sign-up-service/send-console-command command content)
|
(sign-up-service/send-console-command command content)
|
||||||
;; TODO handle command, now sends as plain message
|
;; TODO handle command, now sends as plain message
|
||||||
(let [{msg-id :msg-id
|
(let [{msg-id :msg-id
|
||||||
{from :from
|
{from :from
|
||||||
to :to} :msg} (api/send-user-msg {:to chat-id
|
to :to} :msg} (api/send-user-msg {:to chat-id
|
||||||
:content content})]
|
:content content})]
|
||||||
|
@ -91,6 +91,10 @@
|
|||||||
(-> (r/get-all :contacts)
|
(-> (r/get-all :contacts)
|
||||||
(r/sorted :name :asc)))
|
(r/sorted :name :asc)))
|
||||||
|
|
||||||
|
(defn contatct-by-identity [identity]
|
||||||
|
(-> (r/get-by-field :contacts :whisper-identity identity)
|
||||||
|
(r/single-cljs)))
|
||||||
|
|
||||||
(comment
|
(comment
|
||||||
|
|
||||||
(r/write #(create-contact {:phone-number "0543072333"
|
(r/write #(create-contact {:phone-number "0543072333"
|
||||||
|
@ -28,8 +28,8 @@
|
|||||||
payload :payload} event]
|
payload :payload} event]
|
||||||
(dispatch [:group-received-msg (assoc payload :from from
|
(dispatch [:group-received-msg (assoc payload :from from
|
||||||
:group-id group-id)]))
|
:group-id group-id)]))
|
||||||
;:group-chat-invite-acked (let [{:keys [from group-id]} event]
|
:group-chat-invite-acked (let [{:keys [from group-id ack-msg-id]} event]
|
||||||
; (add-to-chat "group-chat" ":" (str "Received ACK for group chat invitation from " from " for group-id: " group-id)))
|
(dispatch [:group-chat-invite-acked from group-id ack-msg-id]))
|
||||||
;:group-new-participant (let [{:keys [group-id identity from]} event]
|
;: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-to-chat "group-chat" ":" (str (shorten from) " added " (shorten identity) " to group chat"))
|
||||||
; (add-identity-to-group-list identity))
|
; (add-identity-to-group-list identity))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user