Disable images in public chats

Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
This commit is contained in:
Andrea Maria Piana 2020-06-01 11:33:09 +02:00
parent 5720151484
commit e3815db497
No known key found for this signature in database
GPG Key ID: AA6CCA6DE0E06424
5 changed files with 25 additions and 13 deletions

View File

@ -721,6 +721,12 @@
(not (or (chat.models/group-chat? current-chat) (not (or (chat.models/group-chat? current-chat)
(chat.models/public-chat? current-chat))))) (chat.models/public-chat? current-chat)))))
(re-frame/reg-sub
:current-chat/public?
:<- [:chats/current-raw-chat]
(fn [current-chat]
(chat.models/public-chat? current-chat)))
(re-frame/reg-sub (re-frame/reg-sub
:chats/current-chat-message :chats/current-chat-message
:<- [:chats/current-chat] :<- [:chats/current-chat]

View File

@ -77,6 +77,7 @@
cooldown-enabled? [:chats/cooldown-enabled?] cooldown-enabled? [:chats/cooldown-enabled?]
input-bottom-sheet [:chats/current-chat-ui-prop :input-bottom-sheet] input-bottom-sheet [:chats/current-chat-ui-prop :input-bottom-sheet]
one-to-one-chat? [:current-chat/one-to-one-chat?] one-to-one-chat? [:current-chat/one-to-one-chat?]
public? [:current-chat/public?]
reply-message [:chats/reply-message] reply-message [:chats/reply-message]
sending-image [:chats/sending-image]] sending-image [:chats/sending-image]]
(let [input-text-empty? (and (string/blank? (string/trim (or input-text ""))) (let [input-text-empty? (and (string/blank? (string/trim (or input-text "")))
@ -88,7 +89,7 @@
[send-image-view sending-image]) [send-image-view sending-image])
[react/view {:style style/input-container} [react/view {:style style/input-container}
[basic-text-input input-text cooldown-enabled?] [basic-text-input input-text cooldown-enabled?]
(when (and input-text-empty? (not reply-message)) (when (and input-text-empty? (not reply-message) (not public?))
[image/input-button (= :images input-bottom-sheet)]) [image/input-button (= :images input-bottom-sheet)])
(when (and input-text-empty? mainnet? (not reply-message)) (when (and input-text-empty? mainnet? (not reply-message))
[stickers/button (= :stickers input-bottom-sheet)]) [stickers/button (= :stickers input-bottom-sheet)])

View File

@ -38,7 +38,7 @@
appender]) appender])
(defview quoted-message (defview quoted-message
[_ {:keys [from text image]} outgoing current-public-key] [_ {:keys [from text image]} outgoing current-public-key public?]
(letsubs [{:keys [ens-name alias]} [:contacts/contact-name-by-identity from]] (letsubs [{:keys [ens-name alias]} [:contacts/contact-name-by-identity from]]
[react/view {:style (style/quoted-message-container outgoing)} [react/view {:style (style/quoted-message-container outgoing)}
[react/view {:style style/quoted-message-author-container} [react/view {:style style/quoted-message-author-container}
@ -48,7 +48,9 @@
ens-name ens-name
current-public-key current-public-key
(partial style/quoted-message-author outgoing)]] (partial style/quoted-message-author outgoing)]]
(if image (if (and image
;; Disabling images for public-chats
(not public?))
[react/image {:style {:width 56 [react/image {:style {:width 56
:height 56 :height 56
:background-color :black :background-color :black
@ -164,13 +166,13 @@
:height 192}])}) :height 192}])})
(defn text-message (defn text-message
[{:keys [content outgoing current-public-key] :as message}] [{:keys [content outgoing current-public-key public?] :as message}]
[react/touchable-highlight (text-message-press-handlers message) [react/touchable-highlight (text-message-press-handlers message)
[message-bubble-wrapper message [message-bubble-wrapper message
(let [response-to (:response-to content)] (let [response-to (:response-to content)]
[react/view [react/view
(when (and (seq response-to) (:quoted-message message)) (when (and (seq response-to) (:quoted-message message))
[quoted-message response-to (:quoted-message message) outgoing current-public-key]) [quoted-message response-to (:quoted-message message) outgoing current-public-key public?])
[render-parsed-text-with-timestamp message (:parsed-text content)]]) [render-parsed-text-with-timestamp message (:parsed-text content)]])
[message-timestamp message true]]]) [message-timestamp message true]]])
@ -190,13 +192,13 @@
[render-parsed-text message (:parsed-text content)]]]) [render-parsed-text message (:parsed-text content)]]])
(defn emoji-message (defn emoji-message
[{:keys [content current-public-key outgoing] :as message}] [{:keys [content current-public-key outgoing public?] :as message}]
(let [response-to (:response-to content)] (let [response-to (:response-to content)]
[react/touchable-highlight (text-message-press-handlers message) [react/touchable-highlight (text-message-press-handlers message)
[message-bubble-wrapper message [message-bubble-wrapper message
[react/view {:style (style/style-message-text outgoing)} [react/view {:style (style/style-message-text outgoing)}
(when (and (seq response-to) (:quoted-message message)) (when (and (seq response-to) (:quoted-message message))
[quoted-message response-to (:quoted-message message) outgoing current-public-key]) [quoted-message response-to (:quoted-message message) outgoing current-public-key public?])
[react/text {:style (style/emoji-message message)} [react/text {:style (style/emoji-message message)}
(:text content)]] (:text content)]]
[message-timestamp message]]])) [message-timestamp message]]]))
@ -309,7 +311,7 @@
{:content (sheets/sticker-long-press message) {:content (sheets/sticker-long-press message)
:height 64}])})) :height 64}])}))
(defn chat-message [{:keys [content content-type] :as message}] (defn chat-message [{:keys [public? content content-type] :as message}]
(if (= content-type constants/content-type-command) (if (= content-type constants/content-type-command)
[message.command/command-content message-content-wrapper message] [message.command/command-content message-content-wrapper message]
(if (= content-type constants/content-type-system-text) (if (= content-type constants/content-type-system-text)
@ -328,7 +330,9 @@
[react/image {:style {:margin 10 :width 140 :height 140} [react/image {:style {:margin 10 :width 140 :height 140}
;;TODO (perf) move to event ;;TODO (perf) move to event
:source {:uri (contenthash/url (-> content :sticker :hash))}}]] :source {:uri (contenthash/url (-> content :sticker :hash))}}]]
(if (= content-type constants/content-type-image) (if (and (= content-type constants/content-type-image)
;; Disabling images for public-chats
(not public?))
[react/touchable-highlight (image-message-press-handlers message) [react/touchable-highlight (image-message-press-handlers message)
[message-content-image message]] [message-content-image message]]
[unknown-content-type message])))))]))) [unknown-content-type message])))))])))

View File

@ -110,7 +110,7 @@
(debounce/debounce-and-dispatch [:chat.ui/message-visibility-changed e] 5000)) (debounce/debounce-and-dispatch [:chat.ui/message-visibility-changed e] 5000))
(defview messages-view (defview messages-view
[{:keys [group-chat chat-id pending-invite-inviter-name] :as chat}] [{:keys [public? group-chat chat-id pending-invite-inviter-name] :as chat}]
(letsubs [messages [:chats/current-chat-messages-stream] (letsubs [messages [:chats/current-chat-messages-stream]
current-public-key [:multiaccount/public-key]] current-public-key [:multiaccount/public-key]]
[list/flat-list [list/flat-list
@ -131,6 +131,7 @@
(assoc message (assoc message
:incoming-group (and group-chat (not outgoing)) :incoming-group (and group-chat (not outgoing))
:group-chat group-chat :group-chat group-chat
:public? public?
:current-public-key current-public-key)]))) :current-public-key current-public-key)])))
:on-viewable-items-changed on-viewable-items-changed :on-viewable-items-changed on-viewable-items-changed
:on-end-reached #(re-frame/dispatch [:chat.ui/load-more-messages]) :on-end-reached #(re-frame/dispatch [:chat.ui/load-more-messages])

View File

@ -2,7 +2,7 @@
"_comment": "DO NOT EDIT THIS FILE BY HAND. USE 'scripts/update-status-go.sh <tag>' instead", "_comment": "DO NOT EDIT THIS FILE BY HAND. USE 'scripts/update-status-go.sh <tag>' instead",
"owner": "status-im", "owner": "status-im",
"repo": "status-go", "repo": "status-go",
"version": "feature/content-type-images", "version": "v0.54.0",
"commit-sha1": "6301aac7823edca3c670586890af731d1cf9c249", "commit-sha1": "0bffeab9088b20aca046673d77b9a86d1889decb",
"src-sha256": "0qk56d0la7v93akq9133al8fxq66r8x4xfglf0wb4nxqz2hvkjh8" "src-sha256": "07rly3rlkx7h79ccdc51ji8f4hy3y461scj4slfw8xkbcn80hcb1"
} }