diff --git a/src/status_im/contexts/shell/activity_center/notification/mentions/view.cljs b/src/status_im/contexts/shell/activity_center/notification/mentions/view.cljs index 0f2e7f89c6..2d688a3e6e 100644 --- a/src/status_im/contexts/shell/activity_center/notification/mentions/view.cljs +++ b/src/status_im/contexts/shell/activity_center/notification/mentions/view.cljs @@ -9,25 +9,45 @@ [utils.i18n :as i18n] [utils.re-frame :as rf])) +(defn- mention-text + [literal] + (let [mention (rf/sub [:messages/resolve-mention literal])] + [quo/text + {:style style/mention-text + :size :paragraph-1} + (str "@" mention)])) + +(defn- parsed-text->hiccup + [{:keys [literal destination] message-type :type}] + (case message-type + "mention" [mention-text literal] + "link" destination + literal)) + (defn- message-body - [message] - (let [parsed-text (get-in message [:content :parsed-text]) - parsed-text-children (:children (first parsed-text))] - (into [quo/text - {:number-of-lines 1 - :style style/tag-text - :accessibility-label :activity-message-body - :size :paragraph-1}] - (map-indexed (fn [index {:keys [type literal destination]}] - ^{:key index} - (case type - "mention" [quo/text - {:style style/mention-text - :size :paragraph-1} - (str "@" (rf/sub [:messages/resolve-mention literal]))] - "link" destination - literal)) - parsed-text-children)))) + [{:keys [container parsed-text]}] + (into container (map parsed-text->hiccup) parsed-text)) + +(defn- simple-message + [content] + (let [parsed-text (get-in content [:content :parsed-text 0 :children])] + [message-body + {:container [quo/text + {:number-of-lines 1 + :style style/tag-text + :accessibility-label :activity-message-body + :size :paragraph-1}] + :parsed-text parsed-text}])) + +(defn- album-message + [content] + (let [parsed-text (get-in content [0 :parsedText 0 :children]) + images (map :image content)] + [quo/activity-logs-photos + {:photos images + :message-text [message-body + {:container [:<>] + :parsed-text parsed-text}]}])) (defn- swipeable [{:keys [extra-fn]} child] @@ -41,12 +61,12 @@ (defn view [{:keys [notification extra-fn]}] - (let [{:keys [author chat-name community-id chat-id - message read timestamp]} notification - community-chat? (not (string/blank? community-id)) - community-name (rf/sub [:communities/name community-id]) - community-logo (rf/sub [:communities/logo community-id]) - customization-color (rf/sub [:profile/customization-color])] + (let [{:keys [author chat-name community-id chat-id message read timestamp + album-messages]} notification + community-chat? (not (string/blank? community-id)) + community-name (rf/sub [:communities/name community-id]) + community-logo (rf/sub [:communities/logo community-id]) + customization-color (rf/sub [:profile/customization-color])] [swipeable {:extra-fn extra-fn} [gesture/touchable-without-feedback {:on-press (fn [] @@ -74,4 +94,6 @@ :group-name chat-name :blur? true :size 24}])] - :message {:body (message-body message)}}]]])) + :message {:body (if album-messages + [album-message album-messages] + [simple-message message])}}]]])) diff --git a/src/status_im/contexts/shell/activity_center/view.cljs b/src/status_im/contexts/shell/activity_center/view.cljs index 25f9ca6e8e..e6bc06094c 100644 --- a/src/status_im/contexts/shell/activity_center/view.cljs +++ b/src/status_im/contexts/shell/activity_center/view.cljs @@ -24,35 +24,32 @@ [utils.re-frame :as rf])) (defn notification-component - [{:keys [type] :as notification} index] + [{notification-type :type :as notification} index] (let [extra-fn (rn/use-callback (fn [] {:notification notification}) [notification]) props {:notification notification :extra-fn extra-fn}] - ;; Notifications are expensive to render. Without `delay-render` the opening - ;; animation of the Activity Center can be clunky and the time to open the - ;; AC after pressing the bell icon can be high. [rn/view {:style (style/notification-container index)} (cond - (= type types/contact-verification) + (= notification-type types/contact-verification) [contact-verification/view props] - (= type types/contact-request) + (= notification-type types/contact-request) [contact-requests/view props] - (= type types/mention) + (= notification-type types/mention) [mentions/view props] - (= type types/reply) + (= notification-type types/reply) [reply/view props] - (= type types/admin) + (= notification-type types/admin) [admin/view props] - (some types/membership [type]) - (condp = type + (types/membership notification-type) + (condp = notification-type types/private-group-chat [membership/view props] types/community-request [community-request/view props] types/community-kicked [community-kicked/view props]