Remove status message from messages stream
This commit is contained in:
parent
4fe3c63923
commit
1ec7053aee
|
@ -103,20 +103,15 @@
|
||||||
"Transforms message-datemark-groups into flat sequence of messages interspersed with
|
"Transforms message-datemark-groups into flat sequence of messages interspersed with
|
||||||
datemark messages.
|
datemark messages.
|
||||||
Additionaly enhances the messages in message sequence with derived stream context information,
|
Additionaly enhances the messages in message sequence with derived stream context information,
|
||||||
like `:same-author?`, `:same-direction?`, `:last?` and `:last-outgoing?` flags + contact info/status
|
like `:same-author?`, `:same-direction?`, `:last?` and `:last-outgoing?` flags. "
|
||||||
message for the last dategroup."
|
[message-datemark-groups]
|
||||||
[[[last-datemark last-messages] :as message-datemark-groups]]
|
|
||||||
(if (seq message-datemark-groups)
|
(if (seq message-datemark-groups)
|
||||||
(let [messages-seq (mapcat second message-datemark-groups)
|
(let [messages-seq (mapcat second message-datemark-groups)
|
||||||
{last-message-id :message-id} (first messages-seq)
|
{last-message-id :message-id} (first messages-seq)
|
||||||
{last-outgoing-message-id :message-id} (->> messages-seq
|
{last-outgoing-message-id :message-id} (->> messages-seq
|
||||||
(filter :outgoing)
|
(filter :outgoing)
|
||||||
first)]
|
first)]
|
||||||
;; TODO janherich: why the heck do we display contact user info/status in chat as a message in stream ?
|
(->> message-datemark-groups
|
||||||
;; This makes no sense, user wants to have this information always available, not as something which
|
|
||||||
;; scrolls with message stream
|
|
||||||
(->> (conj (rest message-datemark-groups)
|
|
||||||
[last-datemark (conj (into [] last-messages) {:content-type constants/content-type-status})])
|
|
||||||
(mapcat (fn [[datemark messages]]
|
(mapcat (fn [[datemark messages]]
|
||||||
(let [prepared-messages (into []
|
(let [prepared-messages (into []
|
||||||
(map (fn [{:keys [message-id] :as message} previous-message]
|
(map (fn [{:keys [message-id] :as message} previous-message]
|
||||||
|
@ -133,14 +128,13 @@
|
||||||
(concat (rest messages) '(nil))))]
|
(concat (rest messages) '(nil))))]
|
||||||
(conj prepared-messages {:type :datemark
|
(conj prepared-messages {:type :datemark
|
||||||
:value datemark}))))))
|
:value datemark}))))))
|
||||||
;; when no messages are in chat, we need to at least fake-out today datemark + status messages
|
;; when no messages are in chat, we need to at least fake-out today's datemark
|
||||||
(list {:content-type constants/content-type-status}
|
(list {:type :datemark
|
||||||
{:type :datemark
|
|
||||||
:value (i18n/label :t/datetime-today)})))
|
:value (i18n/label :t/datetime-today)})))
|
||||||
|
|
||||||
(reg-sub
|
(reg-sub
|
||||||
:get-chat-messages
|
:get-chat-messages
|
||||||
(fn [[_ chat-id]]
|
(fn [[_ chat-id]]
|
||||||
(subscribe [:get-chat-message-datemark-groups chat-id]))
|
(subscribe [:get-chat-message-datemark-groups chat-id]))
|
||||||
(fn [message-datemark-groups]
|
(fn [message-datemark-groups]
|
||||||
(messages-stream message-datemark-groups)))
|
(messages-stream message-datemark-groups)))
|
||||||
|
|
Loading…
Reference in New Issue