Skip to content

images_action.js

Anoop Nair edited this page Nov 16, 2021 · 5 revisions

Introduction

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.

addImages

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.

addTagToImage

Action to add one tag to an image.

Params

  • payload - object with following shape.
    • tag
    • currentIndex
    • quantityChanged

checkForImagesOnWeb

Action to get images uploaded from website but not yet tagged. Called in HomeScreen.js

  • Makes a GET request 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

decrementSelected

Decrement the count of photos selected for deletion. Called in HomeScreen.js

deleteImage

Action to delete image by id

Params

  • id - {number} the id of the image in state imagesArray
Action
Reducer
Clone this wiki locally