Remove 100ms delay when opening image (#15422)

* remove image delay
This commit is contained in:
Omar Basem 2023-03-21 17:57:26 +04:00 committed by GitHub
parent c38fdec5b7
commit a5d767515d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 16 deletions

View File

@ -13,7 +13,8 @@
[status-im2.contexts.contacts.events :as contacts-store] [status-im2.contexts.contacts.events :as contacts-store]
[status-im.multiaccounts.model :as multiaccounts.model] [status-im.multiaccounts.model :as multiaccounts.model]
[status-im.utils.clocks :as utils.clocks] [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 (defn- get-chat
[cofx chat-id] [cofx chat-id]
@ -338,6 +339,12 @@
[{:keys [db]} shared-element-id] [{:keys [db]} shared-element-id]
{:db (assoc db :shared-element-id 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 (rf/defn exit-lightbox-signal
{:events [:chat.ui/exit-lightbox-signal]} {:events [:chat.ui/exit-lightbox-signal]}
[{:keys [db]} value] [{:keys [db]} value]
@ -357,4 +364,3 @@
{:events [:chat.ui/lightbox-scale]} {:events [:chat.ui/lightbox-scale]}
[{:keys [db]} value] [{:keys [db]} value]
{:db (assoc db :lightbox/scale value)}) {:db (assoc db :lightbox/scale value)})

View File

@ -52,13 +52,11 @@
{:key (:message-id item) {:key (:message-id item)
:active-opacity 1 :active-opacity 1
:on-long-press #(on-long-press message context) :on-long-press #(on-long-press message context)
:on-press (fn [] :on-press #(rf/dispatch [:chat.ui/navigate-to-lightbox
(rf/dispatch [:chat.ui/update-shared-element-id (:message-id item)]) (:message-id item)
(js/setTimeout #(rf/dispatch [:navigate-to :lightbox
{:messages (:album message) {:messages (:album message)
:index index :index index
:insets insets}]) :insets insets}])}
100))}
[fast-image/fast-image [fast-image/fast-image
{:style (style/image dimensions index portrait? images-count) {:style (style/image dimensions index portrait? images-count)
:source {:uri (:image (:content item))} :source {:uri (:image (:content item))}

View File

@ -27,13 +27,11 @@
:key message-id :key message-id
:style {:margin-top (when (pos? index) 10)} :style {:margin-top (when (pos? index) 10)}
:on-long-press on-long-press :on-long-press on-long-press
:on-press (fn [] :on-press #(rf/dispatch [:chat.ui/navigate-to-lightbox
(rf/dispatch [:chat.ui/update-shared-element-id message-id]) message-id
(js/setTimeout #(rf/dispatch [:navigate-to :lightbox
{:messages [message] {:messages [message]
:index 0 :index 0
:insets insets}]) :insets insets}])}
100))}
(when (and (not= text "placeholder") (= index 0)) (when (and (not= text "placeholder") (= index 0))
[rn/view {:style {:margin-bottom 10}} [text/text-content message context]]) [rn/view {:style {:margin-bottom 10}} [text/text-content message context]])
[fast-image/fast-image [fast-image/fast-image