[Fixes: #11452] Don't allow more than x pictures if taken from camera
This commit fixes an issue with taking pictures from camera, where the check for image count was not checked. Signed-off-by: andrey <motor4ik@gmail.com>
This commit is contained in:
parent
caeab2dfae
commit
60511dc483
|
@ -53,6 +53,12 @@
|
|||
(.saveToCameraRoll CameraRoll path)))
|
||||
#(log/error "could not resize image" %)))))))
|
||||
|
||||
(re-frame/reg-fx
|
||||
::chat-open-image-picker-camera
|
||||
(fn []
|
||||
(react/show-image-picker-camera
|
||||
#(re-frame/dispatch [:chat.ui/image-captured (.-path %)]) {})))
|
||||
|
||||
(re-frame/reg-fx
|
||||
::chat-open-image-picker
|
||||
(fn []
|
||||
|
@ -91,8 +97,12 @@
|
|||
|
||||
(fx/defn image-captured
|
||||
{:events [:chat.ui/image-captured]}
|
||||
[_ uri]
|
||||
{::image-selected uri})
|
||||
[{:keys [db]} uri]
|
||||
(let [current-chat-id (:current-chat-id db)
|
||||
images (get-in db [:chats current-chat-id :metadata :sending-image])]
|
||||
(when (and (< (count images) config/max-images-batch)
|
||||
(not (get images uri)))
|
||||
{::image-selected uri})))
|
||||
|
||||
(fx/defn camera-roll-get-photos
|
||||
{:events [:chat.ui/camera-roll-get-photos]}
|
||||
|
@ -135,6 +145,14 @@
|
|||
(when (< (count images) config/max-images-batch)
|
||||
{::chat-open-image-picker nil})))
|
||||
|
||||
(fx/defn chat-show-image-picker-camera
|
||||
{:events [:chat.ui/show-image-picker-camera]}
|
||||
[{:keys [db]}]
|
||||
(let [current-chat-id (:current-chat-id db)
|
||||
images (get-in db [:chats current-chat-id :metadata :sending-image])]
|
||||
(when (< (count images) config/max-images-batch)
|
||||
{::chat-open-image-picker-camera nil})))
|
||||
|
||||
(fx/defn camera-roll-pick
|
||||
{:events [:chat.ui/camera-roll-pick]}
|
||||
[{:keys [db]} uri]
|
||||
|
|
|
@ -15,9 +15,7 @@
|
|||
(defn take-picture []
|
||||
(permissions/request-permissions
|
||||
{:permissions [:camera]
|
||||
:on-allowed (fn []
|
||||
(react/show-image-picker-camera
|
||||
#(re-frame/dispatch [:chat.ui/image-captured (.-path %)]) {}))
|
||||
:on-allowed #(re-frame/dispatch [:chat.ui/show-image-picker-camera])
|
||||
:on-denied (fn []
|
||||
(utils/set-timeout
|
||||
#(utils/show-popup (i18n/label :t/error)
|
||||
|
|
|
@ -15,14 +15,11 @@
|
|||
[status-im.ui.screens.status.views :as status.views]
|
||||
[status-im.ui.screens.status.new.styles :as styles]))
|
||||
|
||||
(defn take-picture []
|
||||
(react/show-image-picker-camera #(re-frame/dispatch [:chat.ui/image-captured (.-path %)]) {}))
|
||||
|
||||
(defn buttons []
|
||||
[react/view styles/buttons
|
||||
[pressable/pressable {:type :scale
|
||||
:accessibility-label :take-picture
|
||||
:on-press take-picture}
|
||||
:on-press #(re-frame/dispatch [:chat.ui/show-image-picker-camera])}
|
||||
[icons/icon :main-icons/camera]]
|
||||
[react/view {:style {:padding-top 8}}
|
||||
[pressable/pressable {:on-press #(re-frame/dispatch [:chat.ui/open-image-picker])
|
||||
|
|
Loading…
Reference in New Issue