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
|
(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]
|
[utils.datetime :as datetime]
|
||||||
[status-im2.config :as config]
|
[status-im2.config :as config]
|
||||||
[status-im2.constants :as constants]
|
[status-im2.constants :as constants]
|
||||||
[react-native.platform :as platform]
|
[react-native.platform :as platform]
|
||||||
[status-im2.common.resources :as resources]
|
[status-im2.common.resources :as resources]
|
||||||
|
[status-im.multiaccounts.core :as multiaccounts]
|
||||||
[status-im2.contexts.shell.jump-to.constants :as shell.constants]))
|
[status-im2.contexts.shell.jump-to.constants :as shell.constants]))
|
||||||
|
|
||||||
;; Helper Functions
|
;; Helper Functions
|
||||||
|
@ -17,44 +19,53 @@
|
||||||
(first images)))})))
|
(first images)))})))
|
||||||
|
|
||||||
(defn get-card-content
|
(defn get-card-content
|
||||||
[chat communities]
|
[{:keys [chat communities group-chat? primary-name]}]
|
||||||
(let [last-message (:last-message chat)]
|
(let [{:keys [content-type content deleted? outgoing deleted-for-me?] :as last-message}
|
||||||
|
(:last-message chat)]
|
||||||
(merge
|
(merge
|
||||||
(when last-message
|
(when last-message
|
||||||
(case (:content-type last-message)
|
(cond
|
||||||
(constants/content-type-text
|
(or deleted-for-me? deleted?)
|
||||||
constants/content-type-emoji)
|
|
||||||
{:content-type constants/content-type-text
|
{: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,
|
;; Currently mock image is used as placeholder,
|
||||||
;; as last-message don't have image
|
;; as last-message don't have image
|
||||||
;; https://github.com/status-im/status-mobile/issues/14625
|
;; 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
|
{:content-type constants/content-type-image
|
||||||
:data [{:source (resources/get-mock-image :photo2)}]}
|
:data [{:source (resources/get-mock-image :photo2)}]}
|
||||||
|
|
||||||
;; Same for sticker, mock image is used
|
;; Same for sticker, mock image is used
|
||||||
constants/content-type-sticker
|
(= content-type constants/content-type-sticker)
|
||||||
{:content-type constants/content-type-sticker
|
{:content-type constants/content-type-sticker
|
||||||
:data {:source (resources/get-mock-image :sticker)}}
|
:data {:source (resources/get-mock-image :sticker)}}
|
||||||
|
|
||||||
;; Mock Image
|
;; Mock Image
|
||||||
constants/content-type-gif
|
(= content-type constants/content-type-gif)
|
||||||
{:content-type constants/content-type-gif
|
{:content-type constants/content-type-gif
|
||||||
:data {:source (resources/get-mock-image :gif)}}
|
:data {:source (resources/get-mock-image :gif)}}
|
||||||
|
|
||||||
constants/content-type-audio
|
(= content-type 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))}
|
: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))]
|
(let [community (get communities (:community-id last-message))]
|
||||||
{:content-type constants/content-type-community
|
{:content-type constants/content-type-community
|
||||||
:data {:avatar (community-avatar community)
|
:data {:avatar (community-avatar community)
|
||||||
:community-name (:name community)}})
|
:community-name (:name community)}})))
|
||||||
|
|
||||||
nil))
|
|
||||||
{:new-notifications? (pos? (:unviewed-messages-count chat))
|
{:new-notifications? (pos? (:unviewed-messages-count chat))
|
||||||
:notification-indicator (if (pos? (:unviewed-mentions-count chat))
|
:notification-indicator (if (pos? (:unviewed-mentions-count chat))
|
||||||
:counter
|
:counter
|
||||||
|
@ -70,15 +81,21 @@
|
||||||
:profile-picture (when profile-picture
|
:profile-picture (when profile-picture
|
||||||
(str profile-picture "&addRing=0"))}
|
(str profile-picture "&addRing=0"))}
|
||||||
:customization-color (or (:customization-color contact) :primary)
|
:customization-color (or (:customization-color contact) :primary)
|
||||||
:content (get-card-content chat communities)
|
:content (get-card-content
|
||||||
|
{:chat chat
|
||||||
|
:communities communities})
|
||||||
:id id}))
|
:id id}))
|
||||||
|
|
||||||
(defn private-group-chat-card
|
(defn private-group-chat-card
|
||||||
[chat id communities]
|
[chat id communities primary-name]
|
||||||
{:title (:chat-name chat)
|
{:title (:chat-name chat)
|
||||||
:avatar-params {}
|
:avatar-params {}
|
||||||
:customization-color (or (:customization-color chat) :primary)
|
: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})
|
:id id})
|
||||||
|
|
||||||
(defn community-card
|
(defn community-card
|
||||||
|
@ -135,9 +152,18 @@
|
||||||
:shell/private-group-chat-card
|
:shell/private-group-chat-card
|
||||||
(fn [[_ id] _]
|
(fn [[_ id] _]
|
||||||
[(re-frame/subscribe [:chats/chat id])
|
[(re-frame/subscribe [:chats/chat id])
|
||||||
(re-frame/subscribe [:communities])])
|
(re-frame/subscribe [:communities])
|
||||||
(fn [[chat communities] [_ id]]
|
(re-frame/subscribe [:contacts/contacts])
|
||||||
(private-group-chat-card chat id communities)))
|
(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
|
(re-frame/reg-sub
|
||||||
:shell/community-card
|
:shell/community-card
|
||||||
|
|
Loading…
Reference in New Issue