Skip to content

Commit

Permalink
wip. basic sketch of fetching id and uploading
Browse files Browse the repository at this point in the history
  • Loading branch information
geohacker committed Dec 3, 2019
1 parent 69d5a14 commit 2a3f364
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
29 changes: 23 additions & 6 deletions app/actions/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { featureToTiles } from '../utils/bbox'
import { setNotification } from './notification'
import { fetchDataForTile, setSelectedFeatures } from './map'
import { getAllRetriable } from '../utils/edit-utils'

import { getPhotosForFeature } from '../utils/photos'
import { getFeatureInChangeset } from '../services/osm-api'
/**
* Retries all retriable edits in the current state
*/
Expand Down Expand Up @@ -96,11 +97,27 @@ export function purgeAllEdits () {
}

export function editUploaded (edit, changesetId) {
return {
type: types.EDIT_UPLOADED,
edit,
changesetId,
timestamp: Number(new Date())
return async (dispatch, getState) => {
dispatch({
type: types.EDIT_UPLOADED,
edit,
changesetId,
timestamp: Number(new Date())
})

// check if there are any photos associated with this edit
if (edit.type === 'create') {
const photos = getState().photos.photos
const associatedPhotos = getPhotosForFeature(photos, edit.id)
if (associatedPhotos.length) {
// get feature id
const featureId = await getFeatureInChangeset(changesetId)
console.log('feature id for this photo', featureId)
// fire action to update each photo feature id
} else {
// no photos associated. nothing to do
}
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/services/observe-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export async function uploadPhoto (dispatch, photo) {
'createdAt': new Date(photo.location.timestamp).toISOString(),
'file': photo.base64,
'heading': photo.location.coords.heading >= 0 ? photo.location.coords.heading : null,
'description': photo.description,
'description': photo.description || '',
'lon': photo.location.coords.longitude,
'lat': photo.location.coords.latitude,
'osmElement': photo.featureId
Expand Down

0 comments on commit 2a3f364

Please sign in to comment.