From a5d767515de007cc59ce5044f51d52e115ea96ef Mon Sep 17 00:00:00 2001 From: Omar Basem Date: Tue, 21 Mar 2023 17:57:26 +0400 Subject: [PATCH] Remove 100ms delay when opening image (#15422) * remove image delay --- src/status_im2/contexts/chat/events.cljs | 10 ++++++++-- .../contexts/chat/messages/content/album/view.cljs | 12 +++++------- .../contexts/chat/messages/content/image/view.cljs | 12 +++++------- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/status_im2/contexts/chat/events.cljs b/src/status_im2/contexts/chat/events.cljs index ce10de5a23..109185fb7a 100644 --- a/src/status_im2/contexts/chat/events.cljs +++ b/src/status_im2/contexts/chat/events.cljs @@ -13,7 +13,8 @@ [status-im2.contexts.contacts.events :as contacts-store] [status-im.multiaccounts.model :as multiaccounts.model] [status-im.utils.clocks :as utils.clocks] - [status-im.utils.types :as types])) + [status-im.utils.types :as types] + [reagent.core :as reagent])) (defn- get-chat [cofx chat-id] @@ -338,6 +339,12 @@ [{:keys [db]} shared-element-id] {:db (assoc db :shared-element-id shared-element-id)}) +(rf/defn navigate-to-lightbox + {:events [:chat.ui/navigate-to-lightbox]} + [{:keys [db]} shared-element-id screen-params] + (reagent/next-tick #(rf/dispatch [:navigate-to :lightbox screen-params])) + {:db (assoc db :shared-element-id shared-element-id)}) + (rf/defn exit-lightbox-signal {:events [:chat.ui/exit-lightbox-signal]} [{:keys [db]} value] @@ -357,4 +364,3 @@ {:events [:chat.ui/lightbox-scale]} [{:keys [db]} value] {:db (assoc db :lightbox/scale value)}) - 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 025602e6e9..865d5ff88c 100644 --- a/src/status_im2/contexts/chat/messages/content/album/view.cljs +++ b/src/status_im2/contexts/chat/messages/content/album/view.cljs @@ -52,13 +52,11 @@ {:key (:message-id item) :active-opacity 1 :on-long-press #(on-long-press message context) - :on-press (fn [] - (rf/dispatch [:chat.ui/update-shared-element-id (:message-id item)]) - (js/setTimeout #(rf/dispatch [:navigate-to :lightbox - {:messages (:album message) - :index index - :insets insets}]) - 100))} + :on-press #(rf/dispatch [:chat.ui/navigate-to-lightbox + (:message-id item) + {:messages (:album message) + :index index + :insets insets}])} [fast-image/fast-image {:style (style/image dimensions index portrait? images-count) :source {:uri (:image (:content item))} 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 0611b862c8..c598994300 100644 --- a/src/status_im2/contexts/chat/messages/content/image/view.cljs +++ b/src/status_im2/contexts/chat/messages/content/image/view.cljs @@ -27,13 +27,11 @@ :key message-id :style {:margin-top (when (pos? index) 10)} :on-long-press on-long-press - :on-press (fn [] - (rf/dispatch [:chat.ui/update-shared-element-id message-id]) - (js/setTimeout #(rf/dispatch [:navigate-to :lightbox - {:messages [message] - :index 0 - :insets insets}]) - 100))} + :on-press #(rf/dispatch [:chat.ui/navigate-to-lightbox + message-id + {:messages [message] + :index 0 + :insets insets}])} (when (and (not= text "placeholder") (= index 0)) [rn/view {:style {:margin-bottom 10}} [text/text-content message context]]) [fast-image/fast-image