Limit max batch of images
There's an issue reported on slow devices when sending a batch of images. All the requests are send concurrently, and the sending of messages is processed concurrently in the background. On slow devices or connection with slow upload speed this may result in expired envelopes, as the POW calculation or the upload takes too long, and either they never leave the device, or worse they reach the mailserver but won't be stored because already expired on arrival. This commit allows setting the max-images-batch config value, setting it to 1 for release and keeping it to 5 for other builds. Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
This commit is contained in:
parent
cb779e1599
commit
a9aeea2e95
1
.env
1
.env
|
@ -24,4 +24,5 @@ QR_READ_TEST_MENU=1
|
|||
ENABLE_ROOT_ALERT=1
|
||||
ENABLE_REFERRAL_INVITE=1
|
||||
ENABLE_QUO_PREVIEW=1
|
||||
MAX_IMAGES_BATCH=5
|
||||
APN_TOPIC=im.status.ethereum.pr
|
||||
|
|
1
.env.e2e
1
.env.e2e
|
@ -23,4 +23,5 @@ KEYCARD_TEST_MENU=1
|
|||
QR_READ_TEST_MENU=1
|
||||
ENABLE_ROOT_ALERT=0
|
||||
ENABLE_REFERRAL_INVITE=1
|
||||
MAX_IMAGES_BATCH=5
|
||||
APN_TOPIC=im.status.ethereum.pr
|
||||
|
|
|
@ -24,4 +24,5 @@ ENABLE_REFERRAL_INVITE=1
|
|||
DISABLE_WALLET_ON_MOBILE_NETWORK=1
|
||||
APN_TOPIC=im.status.ethereum.pr
|
||||
BLANK_PREVIEW=0
|
||||
GOOGLE_FREE=0
|
||||
MAX_IMAGES_BATCH=5
|
||||
GOOGLE_FREE=0
|
||||
|
|
|
@ -18,4 +18,5 @@ PARTITIONED_TOPIC=0
|
|||
CONTRACT_NODES=1
|
||||
ENABLE_ROOT_ALERT=1
|
||||
ENABLE_REFERRAL_INVITE=0
|
||||
BLANK_PREVIEW=0
|
||||
MAX_IMAGES_BATCH=5
|
||||
BLANK_PREVIEW=0
|
||||
|
|
|
@ -16,4 +16,5 @@ SNOOPY=0
|
|||
RPC_NETWORKS_ONLY=1
|
||||
PARTITIONED_TOPIC=0
|
||||
ENABLE_ROOT_ALERT=1
|
||||
MAX_IMAGES_BATCH=1
|
||||
ENABLE_REFERRAL_INVITE=0
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
[status-im.utils.fx :as fx]
|
||||
["@react-native-community/cameraroll" :as CameraRoll]
|
||||
[status-im.utils.types :as types]
|
||||
[status-im.utils.config :as config]
|
||||
[status-im.ui.components.permissions :as permissions]
|
||||
[status-im.ui.components.react :as react]
|
||||
[status-im.utils.image-processing :as image-processing]
|
||||
|
@ -11,7 +12,6 @@
|
|||
[status-im.utils.platform :as platform]))
|
||||
|
||||
(def maximum-image-size-px 2000)
|
||||
(def max-images-batch 5)
|
||||
|
||||
(defn- resize-and-call [uri cb]
|
||||
(react/image-get-size
|
||||
|
@ -63,7 +63,7 @@
|
|||
(when (and platform/ios? (pos? (count images)))
|
||||
(re-frame/dispatch [:chat.ui/clear-sending-images]))
|
||||
(doseq [^js result (if platform/ios?
|
||||
(take max-images-batch images)
|
||||
(take config/max-images-batch images)
|
||||
[images])]
|
||||
(resize-and-call (.-path result)
|
||||
#(re-frame/dispatch [:chat.ui/image-selected (result->id result) %]))))
|
||||
|
@ -132,7 +132,7 @@
|
|||
[{:keys [db]}]
|
||||
(let [current-chat-id (:current-chat-id db)
|
||||
images (get-in db [:chats current-chat-id :metadata :sending-image])]
|
||||
(when (< (count images) max-images-batch)
|
||||
(when (< (count images) config/max-images-batch)
|
||||
{::chat-open-image-picker nil})))
|
||||
|
||||
(fx/defn camera-roll-pick
|
||||
|
@ -143,7 +143,7 @@
|
|||
(if (get-in db [:chats current-chat-id :timeline?])
|
||||
{:db (update-in db [:chats current-chat-id :metadata :sending-image] {uri {:uri uri}})
|
||||
::image-selected uri}
|
||||
(when (and (< (count images) max-images-batch)
|
||||
(when (and (< (count images) config/max-images-batch)
|
||||
(not (get images uri)))
|
||||
{:db (update-in db [:chats current-chat-id :metadata :sending-image] assoc uri {:uri uri})
|
||||
::image-selected uri}))))
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
(:require [status-im.ui.components.react :as react]
|
||||
[status-im.ui.components.icons.vector-icons :as icons]
|
||||
[status-im.ui.components.permissions :as permissions]
|
||||
[status-im.utils.config :as config]
|
||||
[reagent.core :as reagent]
|
||||
[quo.components.animated.pressable :as pressable]
|
||||
[re-frame.core :as re-frame]
|
||||
[quo.design-system.colors :as colors]
|
||||
[status-im.chat.models.images :as images]
|
||||
[quo.core :as quo]
|
||||
[status-im.utils.utils :as utils]
|
||||
[status-im.i18n :as i18n]))
|
||||
|
@ -51,7 +51,7 @@
|
|||
(defn image-preview [uri all-selected first? panel-height]
|
||||
(let [wh (/ (- panel-height 8) 2)
|
||||
selected (get all-selected uri)
|
||||
max-selected (>= (count all-selected) images/max-images-batch)]
|
||||
max-selected (>= (count all-selected) config/max-images-batch)]
|
||||
[react/touchable-highlight {:on-press #(if selected
|
||||
(re-frame/dispatch [:chat.ui/image-unselected uri])
|
||||
(re-frame/dispatch [:chat.ui/camera-roll-pick uri]))
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
(def erc20-contract-warnings-enabled? (enabled? (get-config :ERC20_CONTRACT_WARNINGS)))
|
||||
(def tr-to-talk-enabled? (enabled? (get-config :TRIBUTE_TO_TALK 0)))
|
||||
(def max-message-delivery-attempts (js/parseInt (get-config :MAX_MESSAGE_DELIVERY_ATTEMPTS "6")))
|
||||
(def max-images-batch (js/parseInt (get-config :MAX_IMAGES_BATCH "1")))
|
||||
;; NOTE: only disabled in releases
|
||||
(def local-notifications? (enabled? (get-config :LOCAL_NOTIFICATIONS "1")))
|
||||
(def blank-preview? (enabled? (get-config :BLANK_PREVIEW "1")))
|
||||
|
|
Loading…
Reference in New Issue