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]}] (fn [{:keys [unviewed-messages-count]}]
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 (re-frame/reg-sub
:chats/photo-path :chats/photo-path
:<- [:contacts/contacts] :<- [:contacts/contacts]

View File

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