diff --git a/README.md b/README.md index 8a13a0e..ce790ac 100644 --- a/README.md +++ b/README.md @@ -99,6 +99,7 @@ The app template is designed to be easy for you to _make it your own._ Here's ho If you're not building an image gallery, you don't need the gallery demo code, except perhaps to learn from. To get rid of it, delete: - `/src/routes/gallery` + - the `initializeFilesystem` function in `/src/lib/auth/account.ts` creates directories used by WNFS. Change those to what you need for your app or delete them if you're not using WNFS. 👏 You're ready to start adding custom functionality! 🚀 diff --git a/src/lib/auth/account.ts b/src/lib/auth/account.ts index 3f60d33..a43e6fd 100644 --- a/src/lib/auth/account.ts +++ b/src/lib/auth/account.ts @@ -1,8 +1,11 @@ import * as webnative from 'webnative' +import type FileSystem from 'webnative/fs/index' import { asyncDebounce } from '$lib/utils' import { filesystemStore, sessionStore } from '../../stores' import { getBackupStatus } from '$lib/auth/backup' +import { AREAS } from '$routes/gallery/stores' +import { GALLERY_DIRS } from '$routes/gallery/lib/gallery' export const isUsernameValid = async (username: string): Promise => { return webnative.account.isUsernameValid(username) @@ -27,6 +30,9 @@ export const register = async (username: string): Promise => { const fs = await webnative.bootstrapRootFileSystem() filesystemStore.set(fs) + // TODO Remove if only public and private directories are needed + await initializeFilesystem(fs) + sessionStore.update(session => ({ ...session, username, @@ -36,6 +42,16 @@ export const register = async (username: string): Promise => { return success } +/** + * Create additional directories and files needed by the app + * + * @param fs FileSystem + */ +const initializeFilesystem = async (fs: FileSystem): Promise => { + await fs.mkdir(webnative.path.directory(...GALLERY_DIRS[AREAS.PUBLIC])) + await fs.mkdir(webnative.path.directory(...GALLERY_DIRS[AREAS.PRIVATE])) +} + export const loadAccount = async (username: string): Promise => { await checkDataRoot(username) diff --git a/src/routes/gallery/+layout.svelte b/src/routes/gallery/+layout.svelte deleted file mode 100644 index 586a37d..0000000 --- a/src/routes/gallery/+layout.svelte +++ /dev/null @@ -1,47 +0,0 @@ - - -{#if fsCheckCompleted} - -{/if}