fix deleted message remains in preview at Jump to section (#16385)
This commit is contained in:
parent
4a4974b541
commit
8f21cecf81
|
@ -1,10 +1,12 @@
|
|||
(ns status-im2.subs.shell
|
||||
(:require [re-frame.core :as re-frame]
|
||||
(:require [utils.i18n :as i18n]
|
||||
[re-frame.core :as re-frame]
|
||||
[utils.datetime :as datetime]
|
||||
[status-im2.config :as config]
|
||||
[status-im2.constants :as constants]
|
||||
[react-native.platform :as platform]
|
||||
[status-im2.common.resources :as resources]
|
||||
[status-im.multiaccounts.core :as multiaccounts]
|
||||
[status-im2.contexts.shell.jump-to.constants :as shell.constants]))
|
||||
|
||||
;; Helper Functions
|
||||
|
@ -17,44 +19,53 @@
|
|||
(first images)))})))
|
||||
|
||||
(defn get-card-content
|
||||
[chat communities]
|
||||
(let [last-message (:last-message chat)]
|
||||
[{:keys [chat communities group-chat? primary-name]}]
|
||||
(let [{:keys [content-type content deleted? outgoing deleted-for-me?] :as last-message}
|
||||
(:last-message chat)]
|
||||
(merge
|
||||
(when last-message
|
||||
(case (:content-type last-message)
|
||||
(constants/content-type-text
|
||||
constants/content-type-emoji)
|
||||
(cond
|
||||
(or deleted-for-me? deleted?)
|
||||
{:content-type constants/content-type-text
|
||||
:data (get last-message :content)}
|
||||
:data {:text
|
||||
(if (or deleted-for-me? outgoing)
|
||||
(i18n/label :t/you-deleted-a-message)
|
||||
(if (and group-chat? primary-name)
|
||||
(i18n/label :t/user-deleted-a-message {:user primary-name})
|
||||
(i18n/label :t/this-message-was-deleted)))}}
|
||||
|
||||
(#{constants/content-type-text
|
||||
constants/content-type-emoji}
|
||||
content-type)
|
||||
{:content-type constants/content-type-text
|
||||
:data content}
|
||||
|
||||
;; Currently mock image is used as placeholder,
|
||||
;; as last-message don't have image
|
||||
;; https://github.com/status-im/status-mobile/issues/14625
|
||||
constants/content-type-image
|
||||
(= content-type constants/content-type-image)
|
||||
{:content-type constants/content-type-image
|
||||
:data [{:source (resources/get-mock-image :photo2)}]}
|
||||
|
||||
;; Same for sticker, mock image is used
|
||||
constants/content-type-sticker
|
||||
(= content-type constants/content-type-sticker)
|
||||
{:content-type constants/content-type-sticker
|
||||
:data {:source (resources/get-mock-image :sticker)}}
|
||||
|
||||
;; Mock Image
|
||||
constants/content-type-gif
|
||||
(= content-type constants/content-type-gif)
|
||||
{:content-type constants/content-type-gif
|
||||
:data {:source (resources/get-mock-image :gif)}}
|
||||
|
||||
constants/content-type-audio
|
||||
(= content-type constants/content-type-audio)
|
||||
{:content-type constants/content-type-audio
|
||||
:data (datetime/ms-to-duration (:audio-duration-ms last-message))}
|
||||
|
||||
constants/content-type-community
|
||||
(= content-type constants/content-type-community)
|
||||
(let [community (get communities (:community-id last-message))]
|
||||
{:content-type constants/content-type-community
|
||||
:data {:avatar (community-avatar community)
|
||||
:community-name (:name community)}})
|
||||
|
||||
nil))
|
||||
:community-name (:name community)}})))
|
||||
{:new-notifications? (pos? (:unviewed-messages-count chat))
|
||||
:notification-indicator (if (pos? (:unviewed-mentions-count chat))
|
||||
:counter
|
||||
|
@ -70,15 +81,21 @@
|
|||
:profile-picture (when profile-picture
|
||||
(str profile-picture "&addRing=0"))}
|
||||
:customization-color (or (:customization-color contact) :primary)
|
||||
:content (get-card-content chat communities)
|
||||
:content (get-card-content
|
||||
{:chat chat
|
||||
:communities communities})
|
||||
:id id}))
|
||||
|
||||
(defn private-group-chat-card
|
||||
[chat id communities]
|
||||
[chat id communities primary-name]
|
||||
{:title (:chat-name chat)
|
||||
:avatar-params {}
|
||||
:customization-color (or (:customization-color chat) :primary)
|
||||
:content (get-card-content chat communities)
|
||||
:content (get-card-content
|
||||
{:chat chat
|
||||
:communities communities
|
||||
:group-chat? true
|
||||
:primary-name primary-name})
|
||||
:id id})
|
||||
|
||||
(defn community-card
|
||||
|
@ -135,9 +152,18 @@
|
|||
:shell/private-group-chat-card
|
||||
(fn [[_ id] _]
|
||||
[(re-frame/subscribe [:chats/chat id])
|
||||
(re-frame/subscribe [:communities])])
|
||||
(fn [[chat communities] [_ id]]
|
||||
(private-group-chat-card chat id communities)))
|
||||
(re-frame/subscribe [:communities])
|
||||
(re-frame/subscribe [:contacts/contacts])
|
||||
(re-frame/subscribe [:multiaccount])])
|
||||
(fn [[chat communities contacts current-multiaccount] [_ id]]
|
||||
(let [from (get-in chat [:last-message :from])
|
||||
contact (when from (multiaccounts/contact-by-identity contacts from))
|
||||
primary-name (when from
|
||||
(first (multiaccounts/contact-two-names-by-identity
|
||||
contact
|
||||
current-multiaccount
|
||||
from)))]
|
||||
(private-group-chat-card chat id communities primary-name))))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:shell/community-card
|
||||
|
|
Loading…
Reference in New Issue