-
Notifications
You must be signed in to change notification settings - Fork 2
images_action.js
Anoop Nair edited this page Nov 16, 2021
·
5 revisions
This file contains all the redux actions for images.
There are three types of images in app :
-
CAMERA- These are the images taken from in app camera. -
GALLERY- These are geotagged images imported from phone gallery. -
WEB- These are images uploaded from OLM website but not yet tagged.
Action to add images to state.
Params
-
images- Array of image object. -
type-CAMERA||GALLERY||WEB -
pickedUp-{boolean}Default user setting if litter is picked up or still there.
Action to add one tag to an image.
Params
-
payload- object with following shape.tagcurrentIndexquantityChanged
Action to get images uploaded from website but not yet tagged. Called in HomeScreen.js
- Makes a
GETrequest to api endpoint/api/v2/photos/web/index - if success and untagged photos exist add it to state.
- dispatch with
type: ADD_IMAGES&
payload: {
images: photos, // photos is array of untagged images from api response
type: 'WEB',
picked_up
}Params
-
token- JWT token stored in redux state. -
picked_up- default user setting if litter is picked_up or not
Decrement the count of photos selected for deletion. Called in HomeScreen.js
- dispatches
DECREMENT_SELECTED
Action to delete image by id.
- dispatches
DELETE_IMAGEwith payloadid
Params
-
id- {number} the id of the image in stateimagesArray
Change selected property to false on all the photos in state imagesArray
- dispatches
DESELECT_ALL_IMAGES
Delete WEB image based on the photoId
- Makes a
DELETErequest on api endpoint/api/photos/deleteand sendparams: { photoId }. - If success remove the image from state, dispatch
DELETE_IMAGEwith payloadid
Params
-
token- JWT token stored in redux state. -
photoId- image id in db -
id- image id in stateimagesArray
-
Init
-
Navigation Stacks