Fixed Cocoapods build with many hacks
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -69,7 +69,7 @@ export class Login extends React.Component {
|
||||
constructor(props) {
|
||||
super(props)
|
||||
this.state = {
|
||||
binder: new FormBinder({}, Login.bindings)
|
||||
binder: new FormBinder({email: 'john@lyon-smith.org', password: 'Skunkay'}, Login.bindings)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ export class Login extends React.Component {
|
||||
api.login(obj.email, obj.password, obj.rememberMe).then((user) => {
|
||||
this.props.navigator.dismissAllModals()
|
||||
}).catch((error) => {
|
||||
this.props.navigator.dismissModal()
|
||||
console.error(api.apiURL)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user