diff --git a/src/status_im/events.cljs b/src/status_im/events.cljs index d4460fce1f..f065b82ab0 100644 --- a/src/status_im/events.cljs +++ b/src/status_im/events.cljs @@ -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 diff --git a/src/status_im/native_module/core.cljs b/src/status_im/native_module/core.cljs index b2025ff60f..0af2b03e31 100644 --- a/src/status_im/native_module/core.cljs +++ b/src/status_im/native_module/core.cljs @@ -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" diff --git a/src/status_im2/contexts/chat/messages/content/album/view.cljs b/src/status_im2/contexts/chat/messages/content/album/view.cljs index d8402adb50..2fbf6bcc9e 100644 --- a/src/status_im2/contexts/chat/messages/content/album/view.cljs +++ b/src/status_im2/contexts/chat/messages/content/album/view.cljs @@ -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))]))) diff --git a/src/status_im2/contexts/chat/messages/content/image/view.cljs b/src/status_im2/contexts/chat/messages/content/image/view.cljs index 4fb22fba30..1f8f232950 100644 --- a/src/status_im2/contexts/chat/messages/content/image/view.cljs +++ b/src/status_im2/contexts/chat/messages/content/image/view.cljs @@ -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]) diff --git a/src/status_im2/contexts/chat/messages/content/text/view.cljs b/src/status_im2/contexts/chat/messages/content/text/view.cljs index 2d8cbfdd09..899d0f85cb 100644 --- a/src/status_im2/contexts/chat/messages/content/text/view.cljs +++ b/src/status_im2/contexts/chat/messages/content/text/view.cljs @@ -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]]) diff --git a/src/status_im2/contexts/chat/messages/content/view.cljs b/src/status_im2/contexts/chat/messages/content/view.cljs index db81ed1d85..3d10add85d 100644 --- a/src/status_im2/contexts/chat/messages/content/view.cljs +++ b/src/status_im2/contexts/chat/messages/content/view.cljs @@ -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]]]]])) diff --git a/src/status_im2/contexts/chat/messages/link_preview/view.cljs b/src/status_im2/contexts/chat/messages/link_preview/view.cljs index 609176c33d..f80a93519f 100644 --- a/src/status_im2/contexts/chat/messages/link_preview/view.cljs +++ b/src/status_im2/contexts/chat/messages/link_preview/view.cljs @@ -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? ask-user?) [link-preview-enable-request]))))) \ No newline at end of file + (and link-whitelisted? enabled?) [link-preview-loader link context] + (and link-whitelisted? ask-user?) [link-preview-enable-request])))))