mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Merge branch 'master' of github.com:Human-Connection/Human-Connection into 1488-filter-posts-by-emotion
This commit is contained in:
commit
ba3e0ca941
@ -1,9 +1,12 @@
|
||||
import request from 'request'
|
||||
import { UserInputError } from 'apollo-server'
|
||||
import isEmpty from 'lodash/isEmpty'
|
||||
import Debug from 'debug'
|
||||
import asyncForEach from '../../helpers/asyncForEach'
|
||||
import CONFIG from './../../config'
|
||||
|
||||
const debug = Debug('human-connection:location')
|
||||
|
||||
const fetch = url => {
|
||||
return new Promise((resolve, reject) => {
|
||||
request(url, function(error, response, body) {
|
||||
@ -59,6 +62,7 @@ const createOrUpdateLocations = async (userId, locationName, driver) => {
|
||||
if (isEmpty(locationName)) {
|
||||
return
|
||||
}
|
||||
|
||||
const res = await fetch(
|
||||
`https://api.mapbox.com/geocoding/v5/mapbox.places/${encodeURIComponent(
|
||||
locationName,
|
||||
@ -67,6 +71,8 @@ const createOrUpdateLocations = async (userId, locationName, driver) => {
|
||||
)}`,
|
||||
)
|
||||
|
||||
debug(res)
|
||||
|
||||
if (!res || !res.features || !res.features[0]) {
|
||||
throw new UserInputError('locationName is invalid')
|
||||
}
|
||||
|
||||
@ -101,7 +101,7 @@ export default {
|
||||
async submit() {
|
||||
this.loadingData = true
|
||||
const { name, about } = this.formData
|
||||
let { locationName } = this.formData
|
||||
let { locationName } = this.formData || this.currentUser
|
||||
locationName = locationName && (locationName['label'] || locationName)
|
||||
try {
|
||||
await this.$apollo.mutate({
|
||||
@ -159,7 +159,6 @@ export default {
|
||||
this.cities = []
|
||||
return
|
||||
}
|
||||
|
||||
this.loadingGeo = true
|
||||
this.axiosSource = CancelToken.source()
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user