Fixed Cocoapods build with many hacks

This commit is contained in:
John Lyon-Smith
2018-03-28 11:52:14 -07:00
parent 02e06dface
commit bd5cd8a0d8
1016 changed files with 367 additions and 91366 deletions

View File

@@ -3,14 +3,17 @@ import io from 'socket.io-client'
import { AsyncStorage } from 'react-native'
const authTokenName = 'AuthToken'
let apiURL
let baseURL = null
let apiPath = null
if (__DEV__) {
const localIPAddr = process.env.LOCAL_IP_ADDR
apiURL = `http://${localIPAddr || 'localhost'}:3000`
baseURL = `http://${localIPAddr || 'localhost'}:3001`
apiPath = ''
} else {
apiURL = 'https://dar.kss.us.com/api'
baseURL = 'https://dar.kss.us.com'
apiPath = '/api'
}
class NetworkError extends Error {
@@ -65,8 +68,8 @@ class API extends EventEmitter {
}
connectSocket() {
this.socket = io(apiURL, {
path: '/api/socketio',
this.socket = io(baseURL, {
path: apiPath + '/socketio',
query: {
auth_token: this.token
}
@@ -106,18 +109,22 @@ class API extends EventEmitter {
return this.user
}
get apiURL() {
return baseURL + apiPath
}
makeImageUrl(id, size) {
if (id) {
return '/api/assets/' + id + '?access_token=' + this.token
return apiPath + '/assets/' + id + '?access_token=' + this.token
} else if (size && size.width && size.height) {
return `/api/placeholders/${size.width}x${size.height}?access_token=${this.token}`
return `${apiPath}/placeholders/${size.width}x${size.height}?access_token=${this.token}`
} else {
return null
}
}
makeAssetUrl(id) {
return id ? '/api/assets/' + id + '?access_token=' + this.token : null
return id ? apiPath + '/assets/' + id + '?access_token=' + this.token : null
}
static makeParams(params) {
@@ -150,7 +157,7 @@ class API extends EventEmitter {
}
}
fetchOptions.headers = headers
fetch(apiURL + '/api' + path, fetchOptions).then((res) => {
fetch(this.apiURL + path, fetchOptions).then((res) => {
return Promise.all([ Promise.resolve(res), (requestOptions.binary && method === 'GET') ? res.blob() : res.json() ])
}).then((arr) => {
let [ res, responseBody ] = arr