- add and expand feature stores for entries, fragments, todos, lists, settings - move CRUD logic into store helpers and simplify component state handling - update SidePanel + button to create section-specific items - switch fragment UX to view-first with edit/create modes - add and update docs for store-based state management - remove deprecated account route
51 lines
2.3 KiB
Markdown
51 lines
2.3 KiB
Markdown
# Tauri + SvelteKit + TypeScript
|
|
|
|
This template should help get you started developing with Tauri, SvelteKit and TypeScript in Vite.
|
|
|
|
## Frontend State Management
|
|
|
|
This app uses Svelte stores as the source of truth for feature state.
|
|
|
|
### Current Stores
|
|
|
|
- `src/lib/stores/entries.ts`
|
|
- state: `entriesStore`
|
|
- helpers: `getDefaultEntry`, `createEntryDraft`
|
|
- `src/lib/stores/fragments.ts`
|
|
- state: `fragmentsStore`
|
|
- helpers: parse/serialize + fragment CRUD helpers (`createFragmentItem`, `updateFragmentItem`, `prependFragmentItem`, `removeFragmentItem`)
|
|
- `src/lib/stores/todos.ts`
|
|
- state: `todoListsStore`, `todosStore`
|
|
- helpers: parse/serialize + todo list/item CRUD helpers
|
|
- `src/lib/stores/lists.ts`
|
|
- state: `listsStore`
|
|
- helpers: `createListDraft`
|
|
- `src/lib/stores/settings.ts`
|
|
- state: `settingsTags`, `settingsFragmentTypes`
|
|
|
|
### Store-First Rule
|
|
|
|
- Components should call store helper functions for CRUD operations.
|
|
- Components should avoid embedding feature-specific mutation/parsing logic.
|
|
- UI components should focus on rendering, local form state, and invoking store operations.
|
|
|
|
### What Still Needs Setup
|
|
|
|
1. Move settings CRUD helpers into `settings.ts` (currently add/edit/remove logic lives in `routes/settings/+page.svelte`).
|
|
2. Add full CRUD helpers for `entries` and `lists` stores (update/remove/reorder and optional find-by-id helpers).
|
|
3. Consolidate todo state into a single custom store API (or a single store object) so `todoListsStore` and `todosStore` updates are atomic.
|
|
4. Move calendar-created notes into a dedicated calendar store (currently local to `SidePanel.svelte`).
|
|
5. Add persistence/hydration layer so store state survives app restart and can be synchronized with backend commands.
|
|
|
|
### Suggested Next Refactor
|
|
|
|
- Introduce feature service wrappers per store (for example `entriesService`, `fragmentsService`) that handle:
|
|
- in-memory store mutation
|
|
- backend command call (`sendCommand`)
|
|
- optimistic update / rollback policy
|
|
- error normalization for UI
|
|
|
|
## Recommended IDE Setup
|
|
|
|
[VS Code](https://code.visualstudio.com/) + [Svelte](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode) + [Tauri](https://marketplace.visualstudio.com/items?itemName=tauri-apps.tauri-vscode) + [rust-analyzer](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer).
|