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)
(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
:chats/current-chat-message
:<- [:chats/current-chat]

View File

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

View File

@ -38,7 +38,7 @@
appender])
(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]]
[react/view {:style (style/quoted-message-container outgoing)}
[react/view {:style style/quoted-message-author-container}
@ -48,7 +48,9 @@
ens-name
current-public-key
(partial style/quoted-message-author outgoing)]]
(if image
(if (and image
;; Disabling images for public-chats
(not public?))
[react/image {:style {:width 56
:height 56
:background-color :black
@ -164,13 +166,13 @@
:height 192}])})
(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)
[message-bubble-wrapper message
(let [response-to (:response-to content)]
[react/view
(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)]])
[message-timestamp message true]]])
@ -190,13 +192,13 @@
[render-parsed-text message (:parsed-text content)]]])
(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)]
[react/touchable-highlight (text-message-press-handlers message)
[message-bubble-wrapper message
[react/view {:style (style/style-message-text outgoing)}
(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)}
(:text content)]]
[message-timestamp message]]]))
@ -309,7 +311,7 @@
{:content (sheets/sticker-long-press message)
: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)
[message.command/command-content message-content-wrapper message]
(if (= content-type constants/content-type-system-text)
@ -328,7 +330,9 @@
[react/image {:style {:margin 10 :width 140 :height 140}
;;TODO (perf) move to event
: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)
[message-content-image message]]
[unknown-content-type message])))))])))

View File

@ -110,7 +110,7 @@
(debounce/debounce-and-dispatch [:chat.ui/message-visibility-changed e] 5000))
(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]
current-public-key [:multiaccount/public-key]]
[list/flat-list
@ -131,6 +131,7 @@
(assoc message
:incoming-group (and group-chat (not outgoing))
:group-chat group-chat
:public? public?
:current-public-key current-public-key)])))
:on-viewable-items-changed on-viewable-items-changed
: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",
"owner": "status-im",
"repo": "status-go",
"version": "feature/content-type-images",
"commit-sha1": "6301aac7823edca3c670586890af731d1cf9c249",
"src-sha256": "0qk56d0la7v93akq9133al8fxq66r8x4xfglf0wb4nxqz2hvkjh8"
"version": "v0.54.0",
"commit-sha1": "0bffeab9088b20aca046673d77b9a86d1889decb",
"src-sha256": "07rly3rlkx7h79ccdc51ji8f4hy3y461scj4slfw8xkbcn80hcb1"
}