From 187034cbd68f494a298d4be925d297ad33fee6dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Attila=20Sz=C5=91ke?= Date: Sat, 30 Mar 2024 16:02:17 +0100 Subject: [PATCH] fix: views do not invoke commands anymore, only main app --- .prettierignore | 2 ++ src/App.svelte | 13 ++++---- src/store.ts | 1 + src/view/List.svelte | 75 ++++++++++++++++++-------------------------- 4 files changed, 41 insertions(+), 50 deletions(-) diff --git a/.prettierignore b/.prettierignore index c078aa2..4f55663 100644 --- a/.prettierignore +++ b/.prettierignore @@ -6,3 +6,5 @@ yarn.lock /src-tauri src/bindings.ts /.vscode + +CHANGELOG.md diff --git a/src/App.svelte b/src/App.svelte index 95cb030..18db6b4 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -4,7 +4,7 @@ import Record from './view/Record.svelte'; import Menu from './view/Menu.svelte'; import List from './view/List.svelte'; - import { todaysHighlight } from './store'; + import { highlights, todaysHighlight } from './store'; import Spinner from './lib/components/Spinner.svelte'; import JumpToTopButton from './lib/components/JumpToTopButton.svelte'; import { getToday } from './lib/utils/date'; @@ -40,6 +40,11 @@ }; const toMenu = () => (state = AppState.Menu); + const toList = async () => { + state = AppState.Loading; + $highlights = await commands.listHighlights(); + state = AppState.List; + }; const deleteHighlights = async ({ detail: ids }: CustomEvent) => { await commands.deleteHighlight(ids); @@ -62,11 +67,7 @@ {:else if state === AppState.Menu}
- (state = AppState.Record)} - on:toList={() => (state = AppState.List)} - on:exit={quit} - /> + (state = AppState.Record)} on:toList={toList} on:exit={quit} />
{:else if state === AppState.Record}
diff --git a/src/store.ts b/src/store.ts index e0fc9a1..c210919 100644 --- a/src/store.ts +++ b/src/store.ts @@ -2,3 +2,4 @@ import { writable, type Writable } from 'svelte/store'; import type { Highlight } from './bindings'; export const todaysHighlight: Writable = writable([]); +export const highlights: Writable = writable([]); diff --git a/src/view/List.svelte b/src/view/List.svelte index 51b7127..aa7220f 100644 --- a/src/view/List.svelte +++ b/src/view/List.svelte @@ -1,26 +1,17 @@