From b8fa4f5cbd1919cf3563f26d37a94c0a12302023 Mon Sep 17 00:00:00 2001 From: janherich Date: Fri, 12 Oct 2018 17:32:42 +0200 Subject: [PATCH] Hide unknown referenced messages --- src/status_im/chat/subs.cljs | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/status_im/chat/subs.cljs b/src/status_im/chat/subs.cljs index 960b371352..9868d2a53b 100644 --- a/src/status_im/chat/subs.cljs +++ b/src/status_im/chat/subs.cljs @@ -136,8 +136,8 @@ (defn quoted-message-data "Selects certain data from quoted message which must be available in the view" [message-id messages referenced-messages] - (let [{:keys [from content]} (get messages message-id - (get referenced-messages message-id))] + (when-let [{:keys [from content]} (get messages message-id + (get referenced-messages message-id))] {:from from :text (:text content)})) @@ -149,15 +149,16 @@ (into (list {:value datemark :type :datemark}) (map (fn [{:keys [message-id timestamp-str]}] - (let [{:keys [content] :as message} (get messages message-id)] - (cond-> (assoc message - :datemark datemark - :timestamp-str timestamp-str - :user-statuses (get message-statuses message-id)) - (:response-to content) ;; quoted message reference - (assoc-in [:content :response-to] (quoted-message-data (:response-to content) - messages - referenced-messages)))))) + (let [{:keys [content] :as message} (get messages message-id) + quote (some-> (:response-to content) + (quoted-message-data messages referenced-messages))] + (cond-> (-> message + (update :content dissoc :response-to) + (assoc :datemark datemark + :timestamp-str timestamp-str + :user-statuses (get message-statuses message-id))) + quote ;; quoted message reference + (assoc-in [:content :response-to] quote))))) message-references)) message-groups))