Bootstrap filesystem and add filesystem store

Co-authored-by: Jess Martin <jessmartin@gmail.com>
This commit is contained in:
Brian Ginsburg 2022-07-29 12:58:22 -07:00
parent 264476b004
commit 046c80be44
No known key found for this signature in database
GPG Key ID: B7A01B90EB115B2D
3 changed files with 20 additions and 7 deletions

View File

@ -3,11 +3,12 @@
import { onDestroy, onMount } from 'svelte' import { onDestroy, onMount } from 'svelte'
import { import {
bootstrapFilesystem,
isUsernameValid, isUsernameValid,
isUsernameAvailable, isUsernameAvailable,
register register
} from '$lib/common/webnative' } from '$lib/common/webnative'
import { sessionStore } from '../../stores' import { filesystemStore, sessionStore } from '../../stores'
import type { Session } from '$lib/session' import type { Session } from '$lib/session'
import CheckIcon from '$components/icons/CheckIcon.svelte' import CheckIcon from '$components/icons/CheckIcon.svelte'
import XIcon from '$components/icons/XIcon.svelte' import XIcon from '$components/icons/XIcon.svelte'
@ -54,6 +55,9 @@
console.log('session after registration', $sessionStore) console.log('session after registration', $sessionStore)
const fs = await bootstrapFilesystem()
filesystemStore.set(fs)
goto('/linkDevice') goto('/linkDevice')
} }
} }

View File

@ -1,17 +1,17 @@
import * as webnative from 'webnative' import * as webnative from 'webnative'
// import type FileSystem from 'webnative/fs/index' import type FileSystem from 'webnative/fs/index'
import { setup } from 'webnative' import { setup } from 'webnative'
import { asyncDebounce } from '$lib/common/utils' import { asyncDebounce } from '$lib/common/utils'
import { sessionStore } from '../../stores' import { filesystemStore, sessionStore } from '../../stores'
// runfission.net = staging // runfission.net = staging
setup.endpoints({ api: 'https://runfission.net', user: 'fissionuser.net' }) setup.endpoints({ api: 'https://runfission.net', lobby: 'https://auth.runfission.net', user: 'fissionuser.net' })
let state: webnative.AppState let state: webnative.AppState
// TODO: Add a flag or script to turn debugging on/off // TODO: Add a flag or script to turn debugging on/off
setup.debug({ enabled: true }) setup.debug({ enabled: false })
export const initialize = async (): Promise<void> => { export const initialize = async (): Promise<void> => {
try { try {
@ -32,6 +32,7 @@ export const initialize = async (): Promise<void> => {
authed: state.authenticated, authed: state.authenticated,
loading: false loading: false
}) })
filesystemStore.set(state.fs)
break break
default: default:
@ -79,6 +80,10 @@ export const register = async (username: string): Promise<boolean> => {
return success return success
} }
export const bootstrapFilesystem = async (): Promise<FileSystem> => {
return await webnative.bootstrapRootFileSystem()
}
// interface StateFS { // interface StateFS {
// fs?: FileSystem // fs?: FileSystem
// } // }

View File

@ -1,8 +1,10 @@
import { writable } from 'svelte/store' import { writable } from 'svelte/store'
import type { Writable } from 'svelte/store'
import type FileSystem from 'webnative/fs/index'
import { loadTheme } from '$lib/theme' import { loadTheme } from '$lib/theme'
import type { Session } from '$lib/session' import type { Session } from '$lib/session'
import type { Theme } from '$lib/theme' import type { Theme } from '$lib/theme'
import type { Writable } from 'svelte/store'
export const theme: Writable<Theme> = writable(loadTheme()) export const theme: Writable<Theme> = writable(loadTheme())
@ -11,3 +13,5 @@ export const sessionStore: Writable<Session> = writable({
authed: false, authed: false,
loading: true loading: true
}) })
export const filesystemStore: Writable<FileSystem | null> = writable(null)