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 request from 'request'
|
||||||
import { UserInputError } from 'apollo-server'
|
import { UserInputError } from 'apollo-server'
|
||||||
import isEmpty from 'lodash/isEmpty'
|
import isEmpty from 'lodash/isEmpty'
|
||||||
|
import Debug from 'debug'
|
||||||
import asyncForEach from '../../helpers/asyncForEach'
|
import asyncForEach from '../../helpers/asyncForEach'
|
||||||
import CONFIG from './../../config'
|
import CONFIG from './../../config'
|
||||||
|
|
||||||
|
const debug = Debug('human-connection:location')
|
||||||
|
|
||||||
const fetch = url => {
|
const fetch = url => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
request(url, function(error, response, body) {
|
request(url, function(error, response, body) {
|
||||||
@ -59,6 +62,7 @@ const createOrUpdateLocations = async (userId, locationName, driver) => {
|
|||||||
if (isEmpty(locationName)) {
|
if (isEmpty(locationName)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const res = await fetch(
|
const res = await fetch(
|
||||||
`https://api.mapbox.com/geocoding/v5/mapbox.places/${encodeURIComponent(
|
`https://api.mapbox.com/geocoding/v5/mapbox.places/${encodeURIComponent(
|
||||||
locationName,
|
locationName,
|
||||||
@ -67,6 +71,8 @@ const createOrUpdateLocations = async (userId, locationName, driver) => {
|
|||||||
)}`,
|
)}`,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
debug(res)
|
||||||
|
|
||||||
if (!res || !res.features || !res.features[0]) {
|
if (!res || !res.features || !res.features[0]) {
|
||||||
throw new UserInputError('locationName is invalid')
|
throw new UserInputError('locationName is invalid')
|
||||||
}
|
}
|
||||||
|
|||||||
@ -101,7 +101,7 @@ export default {
|
|||||||
async submit() {
|
async submit() {
|
||||||
this.loadingData = true
|
this.loadingData = true
|
||||||
const { name, about } = this.formData
|
const { name, about } = this.formData
|
||||||
let { locationName } = this.formData
|
let { locationName } = this.formData || this.currentUser
|
||||||
locationName = locationName && (locationName['label'] || locationName)
|
locationName = locationName && (locationName['label'] || locationName)
|
||||||
try {
|
try {
|
||||||
await this.$apollo.mutate({
|
await this.$apollo.mutate({
|
||||||
@ -159,7 +159,6 @@ export default {
|
|||||||
this.cities = []
|
this.cities = []
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
this.loadingGeo = true
|
this.loadingGeo = true
|
||||||
this.axiosSource = CancelToken.source()
|
this.axiosSource = CancelToken.source()
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user