[#14869] Options menu is hardly opened on longtap on messages containing image or links with enabled preview (#14908)
This commit is contained in:
parent
48e5c5c0ec
commit
8b358ab7ed
|
@ -58,6 +58,7 @@
|
|||
status-im.wallet.custom-tokens.core
|
||||
status-im2.contexts.activity-center.events
|
||||
status-im2.contexts.shell.events
|
||||
status-im.chat.models.gaps
|
||||
[status-im2.navigation.events :as navigation]))
|
||||
|
||||
(re-frame/reg-fx
|
||||
|
|
|
@ -471,15 +471,15 @@
|
|||
(defn generate-gfycat
|
||||
"Generate a 3 words random name based on the user public-key, synchronously"
|
||||
[public-key]
|
||||
{:pre [(utils.db/valid-public-key? public-key)]}
|
||||
(log/debug "[native-module] generate-gfycat")
|
||||
(.generateAlias ^js (status) public-key))
|
||||
(when (utils.db/valid-public-key? public-key)
|
||||
(.generateAlias ^js (status) public-key)))
|
||||
|
||||
(defn generate-gfycat-async
|
||||
"Generate a 3 words random name based on the user public-key, asynchronously"
|
||||
[public-key callback]
|
||||
{:pre [(utils.db/valid-public-key? public-key)]}
|
||||
(.generateAliasAsync ^js (status) public-key callback))
|
||||
(when (utils.db/valid-public-key? public-key)
|
||||
(.generateAliasAsync ^js (status) public-key callback)))
|
||||
|
||||
(defn identicon
|
||||
"Generate a icon based on a string, synchronously"
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
{:width (second size-arr) :height (first size-arr) :album-style album-style}))
|
||||
|
||||
(defn album-message
|
||||
[{:keys [albumize?] :as message}]
|
||||
[{:keys [albumize?] :as message} {:keys [on-long-press] :as context}]
|
||||
(let [shared-element-id (rf/sub [:shared-element-id])
|
||||
first-image (first (:album message))
|
||||
album-style (if (> (:image-width first-image) (:image-height first-image))
|
||||
|
@ -69,7 +69,8 @@
|
|||
(rf/dispatch [:chat.ui/update-shared-element-id (:message-id item)])
|
||||
(js/setTimeout #(rf/dispatch [:chat.ui/navigate-to-horizontal-images
|
||||
(:album message) index])
|
||||
100))}
|
||||
100))
|
||||
:on-long-press on-long-press}
|
||||
[rn/image
|
||||
{:style (merge
|
||||
(style/image dimensions index)
|
||||
|
@ -90,10 +91,10 @@
|
|||
:size :heading-2
|
||||
:style {:color colors/white}}
|
||||
(str "+" (- images-count (dec max-display-count)))]])]))
|
||||
(:album message))
|
||||
]
|
||||
(:album message))]
|
||||
|
||||
[:<>
|
||||
(map-indexed
|
||||
(fn [index item]
|
||||
[image/image-message index item])
|
||||
[image/image-message index item context])
|
||||
(:album message))])))
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
{:width calculated-width :height calculated-height}))))
|
||||
|
||||
(defn image-message
|
||||
[index {:keys [content image-width image-height message-id] :as message}]
|
||||
[index {:keys [content image-width image-height message-id] :as message} {:keys [on-long-press]}]
|
||||
(let [dimensions (calculate-dimensions (or image-width 1000) (or image-height 1000))
|
||||
text (:text content)]
|
||||
(fn []
|
||||
|
@ -27,7 +27,8 @@
|
|||
(rf/dispatch [:chat.ui/update-shared-element-id message-id])
|
||||
(js/setTimeout #(rf/dispatch [:chat.ui/navigate-to-horizontal-images
|
||||
[message] 0])
|
||||
100))}
|
||||
100))
|
||||
:on-long-press on-long-press}
|
||||
;; This text comp is temporary. Should later use
|
||||
;; `status-im2.contexts.chat.messages.content.text.view`
|
||||
(when (and (not= text "placeholder") (= index 0)) [rn/text text])
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
[status-im2.contexts.chat.messages.link-preview.view :as link-preview]))
|
||||
|
||||
(defn text-content
|
||||
[message-data]
|
||||
[message-data context]
|
||||
[rn/view
|
||||
[old-message/render-parsed-text message-data]
|
||||
[link-preview/link-preview message-data]])
|
||||
[link-preview/link-preview message-data context]])
|
||||
|
|
|
@ -66,16 +66,20 @@
|
|||
constants/content-type-contact-request [not-implemented/not-implemented
|
||||
[old-message/system-contact-request message-data]])))
|
||||
|
||||
(defn message-on-long-press
|
||||
[message-data context]
|
||||
(rf/dispatch [:bottom-sheet/show-sheet
|
||||
{:content (drawers/reactions-and-actions message-data context)}]))
|
||||
|
||||
(defn user-message-content
|
||||
[{:keys [content-type quoted-message content] :as message-data}
|
||||
{:keys [chat-id] :as context}]
|
||||
(let [response-to (:response-to content)]
|
||||
(let [context (assoc context :on-long-press #(message-on-long-press message-data context))
|
||||
response-to (:response-to content)]
|
||||
[rn/touchable-highlight
|
||||
{:underlay-color (colors/theme-colors colors/neutral-5 colors/neutral-90)
|
||||
:style {:border-radius 16}
|
||||
:on-press #()
|
||||
:on-long-press #(rf/dispatch [:bottom-sheet/show-sheet
|
||||
{:content (drawers/reactions-and-actions message-data context)}])}
|
||||
:on-long-press #(message-on-long-press message-data context)}
|
||||
[rn/view {:padding-vertical 8}
|
||||
(when (and (seq response-to) quoted-message)
|
||||
[old-message/quoted-message {:message-id response-to :chat-id chat-id} quoted-message])
|
||||
|
@ -86,7 +90,7 @@
|
|||
(case content-type
|
||||
|
||||
constants/content-type-text [not-implemented/not-implemented
|
||||
[content.text/text-content message-data]]
|
||||
[content.text/text-content message-data context]]
|
||||
|
||||
constants/content-type-emoji [not-implemented/not-implemented
|
||||
[old-message/emoji message-data]]
|
||||
|
@ -94,12 +98,12 @@
|
|||
constants/content-type-sticker [not-implemented/not-implemented
|
||||
[old-message/sticker message-data]]
|
||||
|
||||
constants/content-type-image [image/image-message 0 message-data]
|
||||
constants/content-type-image [image/image-message 0 message-data context]
|
||||
|
||||
constants/content-type-audio [not-implemented/not-implemented
|
||||
[old-message/audio message-data]]
|
||||
|
||||
constants/content-type-album [album/album-message message-data]
|
||||
constants/content-type-album [album/album-message message-data context]
|
||||
|
||||
[not-implemented/not-implemented [content.unknown/unknown-content message-data]])
|
||||
[status/status message-data]]]]]))
|
||||
|
|
|
@ -87,7 +87,7 @@
|
|||
[community-preview cached-preview-data]))})))
|
||||
|
||||
(defn link-preview-loader
|
||||
[link]
|
||||
[link {:keys [on-long-press]}]
|
||||
(reagent/create-class
|
||||
{:component-did-mount
|
||||
(fn []
|
||||
|
@ -98,10 +98,11 @@
|
|||
(when-let [{:keys [site title thumbnail-url error] :as preview-data} cached-preview-data]
|
||||
(when (and (not error) site title)
|
||||
[rn/touchable-opacity
|
||||
{:style (when-not (is-gif? thumbnail-url)
|
||||
{:align-self :stretch})
|
||||
:on-press #(when (security/safe-link? link)
|
||||
(rf/dispatch [:browser.ui/message-link-pressed link]))}
|
||||
{:style (when-not (is-gif? thumbnail-url)
|
||||
{:align-self :stretch})
|
||||
:on-press #(when (security/safe-link? link)
|
||||
(rf/dispatch [:browser.ui/message-link-pressed link]))
|
||||
:on-long-press on-long-press}
|
||||
[rn/view (style/wrapper)
|
||||
(when-not (is-gif? thumbnail-url)
|
||||
[:<>
|
||||
|
@ -140,7 +141,7 @@
|
|||
(i18n/label :t/dont-ask)]])
|
||||
|
||||
(defn link-preview
|
||||
[{:keys [content]}]
|
||||
[{:keys [content]} context]
|
||||
(let [links (:links content)
|
||||
ask-user? (rf/sub [:link-preview/link-preview-request-enabled])
|
||||
enabled-sites (rf/sub [:link-preview/enabled-sites])
|
||||
|
@ -154,5 +155,5 @@
|
|||
link-whitelisted? (and link whitelisted?)]
|
||||
(cond
|
||||
community? [community-preview-loader link]
|
||||
(and link-whitelisted? enabled?) [link-preview-loader link]
|
||||
(and link-whitelisted? enabled?) [link-preview-loader link context]
|
||||
(and link-whitelisted? ask-user?) [link-preview-enable-request])))))
|
Loading…
Reference in New Issue