revert unnecessary :chats/last-message-content subscription

Signed-off-by: Andrey Shovkoplyas <motor4ik@gmail.com>
This commit is contained in:
bitsikka 2019-09-03 13:30:58 +05:45 committed by Andrey Shovkoplyas
parent ba8e49b649
commit df66b73054
No known key found for this signature in database
GPG Key ID: EAAB7C8622D860A4
2 changed files with 47 additions and 54 deletions

View File

@ -715,16 +715,6 @@
(fn [{:keys [unviewed-messages-count]}]
unviewed-messages-count))
(re-frame/reg-sub
:chats/last-message-content
(fn [[_ chat-id]]
(re-frame/subscribe [:chats/chat chat-id]))
(fn [{:keys [last-message-content last-message-content-type timestamp last-message-timestamp]}]
{:content last-message-content
:content-type last-message-content-type
:last-message-timestamp last-message-timestamp
:timestamp timestamp}))
(re-frame/reg-sub
:chats/photo-path
:<- [:contacts/contacts]

View File

@ -24,8 +24,7 @@
(when-let [command (commands-receiving/lookup-command-by-ref message id->command)]
(commands/generate-short-preview command (commands/add-chat-contacts contacts message)))))
(defview message-content-text [chat-id]
(letsubs [{:keys [content content-type] :as message} [:chats/last-message-content chat-id]]
(defn message-content-text [{:keys [content content-type] :as message}]
[react/view styles/last-message-container
(cond
@ -55,15 +54,13 @@
[react/text {:style styles/last-message-text
:number-of-lines 1
:accessibility-label :chat-message-text}
content])]))
content])])
(defview message-timestamp [chat-id]
(letsubs [{:keys [last-message-timestamp timestamp]} [:chats/last-message-content chat-id]]
(let [ts (if (pos? last-message-timestamp) last-message-timestamp timestamp)]
(when ts
(defn message-timestamp [timestamp]
(when timestamp
[react/text {:style styles/datetime-text
:accessibility-label :last-message-time-text}
(string/upper-case (time/to-short-str ts))]))))
(string/upper-case (time/to-short-str timestamp))]))
(defview unviewed-indicator [chat-id]
(letsubs [unviewed-messages-count [:chats/unviewed-messages-count chat-id]]
@ -76,8 +73,11 @@
(let [{:keys
[chat-id chat-name name
color online group-chat
public? public-key
contact]} home-item
public? public-key contact
last-message-timestamp
timestamp
last-message-content
last-message-content-type]} home-item
private-group? (and group-chat (not public?))
public-group? (and group-chat public?)
truncated-chat-name (utils/truncate-str chat-name 30)
@ -94,11 +94,14 @@
:else nil)
:title truncated-chat-name
:title-accessibility-label :chat-name-text
:title-row-accessory [message-timestamp chat-id]
:title-row-accessory [message-timestamp (if (pos? last-message-timestamp)
last-message-timestamp
timestamp)]
:subtitle
(let [{:keys [tribute-status tribute-label]} (:tribute-to-talk contact)]
(if (not (#{:require :pending} tribute-status))
[message-content-text chat-id]
[message-content-text {:content last-message-content
:content-type last-message-content-type}]
tribute-label))
:subtitle-row-accessory [unviewed-indicator chat-id]
:on-press #(do