Start adding API selection modal and supporting code

This commit is contained in:
John Lyon-Smith
2018-04-08 20:53:01 -07:00
parent 7891bb71c9
commit d674f5e7eb
6 changed files with 171 additions and 41 deletions

View File

@@ -3,6 +3,8 @@ import io from "socket.io-client"
import { AsyncStorage } from "react-native"
const authTokenName = "AuthToken"
const backendName = "backendName"
let baseURL = null
let apiPath = null
//
@@ -46,6 +48,15 @@ class API extends EventEmitter {
super()
this.user = { pending: true }
AsyncStorage.getItem(backendName)
.then((backend) => {
this.backend = backend
})
.catch((err) => {
this.backend = "normal"
AsyncStorage.setItem(backendName, this.backend)
})
AsyncStorage.getItem(authTokenName)
.then((token) => {
if (!token) {
@@ -105,8 +116,8 @@ class API extends EventEmitter {
return this.user
}
get apiURL() {
return baseURL + apiPath
get backend() {
return this.backend
}
makeImageUrl(id, size) {