diff --git a/src/state/index.ts b/src/state/index.ts index 78c14714..0716ab59 100644 --- a/src/state/index.ts +++ b/src/state/index.ts @@ -4,8 +4,8 @@ import {RootStoreModel} from './models/root-store' import * as libapi from './lib/api' import * as storage from './lib/storage' +export const DEFAULT_SERVICE = 'http://localhost:2583' const ROOT_STATE_STORAGE_KEY = 'root' -const DEFAULT_SERVICE = 'http://localhost:2583' const STATE_FETCH_INTERVAL = 15e3 export async function setupState() { diff --git a/src/state/models/root-store.ts b/src/state/models/root-store.ts index 68b042d6..717caa4a 100644 --- a/src/state/models/root-store.ts +++ b/src/state/models/root-store.ts @@ -74,7 +74,7 @@ export class RootStoreModel { } } -const throwawayInst = new RootStoreModel(AtpApi.service('http://localhost')) // this will be replaced by the loader +const throwawayInst = new RootStoreModel(AtpApi.service('http://localhost')) // this will be replaced by the loader, we just need to supply a value at init const RootStoreContext = createContext(throwawayInst) export const RootStoreProvider = RootStoreContext.Provider export const useStores = () => useContext(RootStoreContext) diff --git a/src/view/screens/Login.tsx b/src/view/screens/Login.tsx index 96c01032..7e5ab429 100644 --- a/src/view/screens/Login.tsx +++ b/src/view/screens/Login.tsx @@ -15,7 +15,7 @@ import * as EmailValidator from 'email-validator' import {observer} from 'mobx-react-lite' import {Picker} from '../com/util/Picker' import {s, colors} from '../lib/styles' -import {useStores} from '../../state' +import {useStores, DEFAULT_SERVICE} from '../../state' import {ServiceDescription} from '../../state/models/session' enum ScreenState { @@ -117,7 +117,7 @@ const Signin = ({onPressBack}: {onPressBack: () => void}) => { setIsProcessing(true) try { await store.session.login({ - service: 'http://localhost:2583/', + service: DEFAULT_SERVICE, handle, password, }) @@ -218,7 +218,7 @@ const CreateAccount = ({onPressBack}: {onPressBack: () => void}) => { if (serviceDescription || error) { return } - store.session.describeService('http://localhost:2583/').then( + store.session.describeService(DEFAULT_SERVICE).then( desc => { if (aborted) return setServiceDescription(desc) @@ -254,7 +254,7 @@ const CreateAccount = ({onPressBack}: {onPressBack: () => void}) => { setIsProcessing(true) try { await store.session.createAccount({ - service: 'http://localhost:2583/', + service: DEFAULT_SERVICE, email, handle: `${handle}.${userDomain}`, password,