[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
36f90fc567
commit
d260ea9e03
|
@ -53,6 +53,12 @@
|
||||||
(.saveToCameraRoll CameraRoll path)))
|
(.saveToCameraRoll CameraRoll path)))
|
||||||
#(log/error "could not resize image" %)))))))
|
#(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
|
(re-frame/reg-fx
|
||||||
::chat-open-image-picker
|
::chat-open-image-picker
|
||||||
(fn []
|
(fn []
|
||||||
|
@ -91,8 +97,12 @@
|
||||||
|
|
||||||
(fx/defn image-captured
|
(fx/defn image-captured
|
||||||
{:events [:chat.ui/image-captured]}
|
{:events [:chat.ui/image-captured]}
|
||||||
[_ uri]
|
[{:keys [db]} uri]
|
||||||
{::image-selected 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
|
(fx/defn camera-roll-get-photos
|
||||||
{:events [:chat.ui/camera-roll-get-photos]}
|
{:events [:chat.ui/camera-roll-get-photos]}
|
||||||
|
@ -135,6 +145,14 @@
|
||||||
(when (< (count images) config/max-images-batch)
|
(when (< (count images) config/max-images-batch)
|
||||||
{::chat-open-image-picker nil})))
|
{::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
|
(fx/defn camera-roll-pick
|
||||||
{:events [:chat.ui/camera-roll-pick]}
|
{:events [:chat.ui/camera-roll-pick]}
|
||||||
[{:keys [db]} uri]
|
[{:keys [db]} uri]
|
||||||
|
|
|
@ -15,9 +15,7 @@
|
||||||
(defn take-picture []
|
(defn take-picture []
|
||||||
(permissions/request-permissions
|
(permissions/request-permissions
|
||||||
{:permissions [:camera]
|
{:permissions [:camera]
|
||||||
:on-allowed (fn []
|
:on-allowed #(re-frame/dispatch [:chat.ui/show-image-picker-camera])
|
||||||
(react/show-image-picker-camera
|
|
||||||
#(re-frame/dispatch [:chat.ui/image-captured (.-path %)]) {}))
|
|
||||||
:on-denied (fn []
|
:on-denied (fn []
|
||||||
(utils/set-timeout
|
(utils/set-timeout
|
||||||
#(utils/show-popup (i18n/label :t/error)
|
#(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.views :as status.views]
|
||||||
[status-im.ui.screens.status.new.styles :as styles]))
|
[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 []
|
(defn buttons []
|
||||||
[react/view styles/buttons
|
[react/view styles/buttons
|
||||||
[pressable/pressable {:type :scale
|
[pressable/pressable {:type :scale
|
||||||
:accessibility-label :take-picture
|
:accessibility-label :take-picture
|
||||||
:on-press take-picture}
|
:on-press #(re-frame/dispatch [:chat.ui/show-image-picker-camera])}
|
||||||
[icons/icon :main-icons/camera]]
|
[icons/icon :main-icons/camera]]
|
||||||
[react/view {:style {:padding-top 8}}
|
[react/view {:style {:padding-top 8}}
|
||||||
[pressable/pressable {:on-press #(re-frame/dispatch [:chat.ui/open-image-picker])
|
[pressable/pressable {:on-press #(re-frame/dispatch [:chat.ui/open-image-picker])
|
||||||
|
|
Loading…
Reference in New Issue