Add mock API and reorg code for clarity

This commit is contained in:
Paul Frazee 2022-07-18 15:24:37 -05:00
parent de87ec17d1
commit 1d00f3b984
29 changed files with 356 additions and 168 deletions

View file

@ -5,8 +5,8 @@ import {
createDefaultRootStore,
} from './models/root-store'
import {Environment} from './env'
import * as storage from './storage'
import * as auth from './auth'
import * as storage from './lib/storage'
// import * as auth from './auth' TODO
const ROOT_STATE_STORAGE_KEY = 'root'
@ -29,15 +29,19 @@ export async function setupState() {
storage.save(ROOT_STATE_STORAGE_KEY, snapshot),
)
if (env.authStore) {
const isAuthed = await auth.isAuthed(env.authStore)
rootStore.session.setAuthed(isAuthed)
// TODO
rootStore.session.setAuthed(true)
// if (env.authStore) {
// const isAuthed = await auth.isAuthed(env.authStore)
// rootStore.session.setAuthed(isAuthed)
// handle redirect from auth
if (await auth.initialLoadUcanCheck(env.authStore)) {
rootStore.session.setAuthed(true)
}
}
// // handle redirect from auth
// if (await auth.initialLoadUcanCheck(env.authStore)) {
// rootStore.session.setAuthed(true)
// }
// }
await rootStore.me.load()
console.log(rootStore.me)
return rootStore
}