Start adding API selection modal and supporting code
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user