mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-18 19:21:23 +02:00
fix(todo): homepage loading state + completed date on task items
Homepage fixes: - Add loading state: show TaskListSkeleton while liveQuery loads - Fix $derived(() => ...) anti-pattern → $derived.by() - Stabilize date calculations (compute once, not per re-render) - Remove double error check (mutation errors shown via toast) TaskItem improvements: - Show completed-at date (small, 50% opacity) on right side of completed tasks - Click completed date to toggle showing created-at date above it Shared: Add `loading` field to useLiveQueryWithDefault (was missing, prevented proper loading states in consumers) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
a81a1535f6
commit
d9e2aeff99
3 changed files with 89 additions and 35 deletions
|
|
@ -82,8 +82,9 @@ export function useLiveQuery<T>(querier: () => T | Promise<T>): LiveQueryResult<
|
|||
export function useLiveQueryWithDefault<T>(
|
||||
querier: () => T | Promise<T>,
|
||||
defaultValue: T
|
||||
): { readonly value: T; readonly error: unknown } {
|
||||
): { readonly value: T; readonly loading: boolean; readonly error: unknown } {
|
||||
let value = $state<T>(defaultValue);
|
||||
let loading = $state(true);
|
||||
let error = $state<unknown>(undefined);
|
||||
|
||||
const observable: Observable<T> = liveQuery(querier);
|
||||
|
|
@ -91,10 +92,12 @@ export function useLiveQueryWithDefault<T>(
|
|||
const subscription = observable.subscribe({
|
||||
next: (result) => {
|
||||
value = result;
|
||||
loading = false;
|
||||
error = undefined;
|
||||
},
|
||||
error: (err) => {
|
||||
error = err;
|
||||
loading = false;
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -106,6 +109,9 @@ export function useLiveQueryWithDefault<T>(
|
|||
get value() {
|
||||
return value;
|
||||
},
|
||||
get loading() {
|
||||
return loading;
|
||||
},
|
||||
get error() {
|
||||
return error;
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue