Dont send unprocessed images

When selecting an image from camera roll we would immediately setting
the filepath with the raw image, process and later once it was processed
we would replace the file path.
On slow devices, the user might press send while the image is still
processing, causing the raw image to be sent, which might be discarded
as too large and never sent.

This commit changes the behavior so that we only set the uri once the
image is processed, it might add some delay, but the image should be
correctly sent.

Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
This commit is contained in:
Andrea Maria Piana 2020-11-19 14:36:19 +01:00
parent 22c6635d93
commit 36f90fc567
No known key found for this signature in database
GPG Key ID: AA6CCA6DE0E06424
1 changed files with 2 additions and 3 deletions

View File

@ -141,12 +141,11 @@
(let [current-chat-id (:current-chat-id db)
images (get-in db [:chats current-chat-id :metadata :sending-image])]
(if (get-in db [:chats current-chat-id :timeline?])
{:db (update-in db [:chats current-chat-id :metadata :sending-image] {uri {:uri uri}})
{:db (assoc-in db [:chats current-chat-id :metadata :sending-image] {})
::image-selected uri}
(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}))))
{::image-selected uri}))))
(fx/defn save-image-to-gallery
{:events [:chat.ui/save-image-to-gallery]}