Skip to content

Commit

Permalink
fix focus and blur events for setting feature id. filter photos that …
Browse files Browse the repository at this point in the history
…have temp ids before uploading
  • Loading branch information
geohacker committed Dec 2, 2019
1 parent b59e996 commit 69d5a14
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
5 changes: 4 additions & 1 deletion app/actions/camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,10 @@ export function deletePhoto (photo) {
export function uploadPendingPhotos () {
return async (dispatch, getState) => {
const { photos } = getState().photos
const pendingPhotos = photos.filter(photo => photo.status === 'pending')
const pendingPhotos = photos.filter(photo => {
// filter pending and photos that are associated with uploaded features
return (photo.status === 'pending' && (photo.featureId === null || photo.featureId.search('observe-') === -1))
})
for (let photo of pendingPhotos) {
dispatch(uploadingPhoto(photo))
try {
Expand Down
20 changes: 19 additions & 1 deletion app/screens/CameraScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,16 @@ class CameraScreen extends React.Component {
feature: null
}

async componentWillMount () {
async componentDidMount () {
this.props.navigation.addListener('willFocus', payload => {
this.willFocus()
})
this.props.navigation.addListener('willBlur', payload => {
this.willBlur()
})
}

async willFocus () {
const { status } = await Permissions.askAsync(Permissions.CAMERA)
const { navigation } = this.props
const { state: { params: { feature } } } = navigation
Expand All @@ -81,6 +90,15 @@ class CameraScreen extends React.Component {
})
}

willBlur () {
this.setState({
image: null,
location: null,
description: null,
feature: null
})
}

async snap () {
if (this.camera) {
let { uri, width, height } = await this.camera.takePictureAsync()
Expand Down

0 comments on commit 69d5a14

Please sign in to comment.