working api create note, view note, view notes, create task with ui

This commit is contained in:
2026-02-27 14:53:53 -06:00
parent 20a19006d5
commit 89b5063786
3 changed files with 58 additions and 25 deletions
+25 -10
View File
@@ -1,4 +1,4 @@
import { type Component, createSignal, Show, onMount, onCleanup, lazy, Suspense } from 'solid-js';
import { type Component, createSignal, onMount, onCleanup, createMemo, lazy, Suspense, Show } from 'solid-js';
import { Layout } from './components/Layout';
import { EmbedLayout } from './components/EmbedLayout';
import { EmbedAuthWrapper } from './components/EmbedAuthWrapper';
@@ -23,8 +23,13 @@ const App: Component = () => {
// Basic routing state
const [currentView, setCurrentView] = createSignal("critical");
const [isAuthenticated, setIsAuthenticated] = createSignal(pb.authStore.isValid);
const [location, setLocation] = createSignal(window.location.href);
onMount(() => {
const handleLocChange = () => setLocation(window.location.href);
window.addEventListener('popstate', handleLocChange);
window.addEventListener('hashchange', handleLocChange);
const removeListener = pb.authStore.onChange((token) => {
console.log('[DEBUG] pb.authStore.onChange fired, token present:', !!token);
setIsAuthenticated(!!token);
@@ -33,7 +38,11 @@ const App: Component = () => {
}
}, true);
onCleanup(() => removeListener());
onCleanup(() => {
removeListener();
window.removeEventListener('popstate', handleLocChange);
window.removeEventListener('hashchange', handleLocChange);
});
// Background preload of other views when idle
const idleCallback = (window as any).requestIdleCallback || ((cb: any) => setTimeout(cb, 1000));
@@ -59,15 +68,19 @@ const App: Component = () => {
// Determine if we are in an embed route (check both path and hash for compatibility)
const isEmbed = () => {
const path = window.location.pathname;
const hash = window.location.hash;
const loc = location(); // Reactive dependency
const url = new URL(loc);
const path = url.pathname;
const hash = url.hash;
const res = path.startsWith('/embed/') || hash.startsWith('#/embed/');
console.log('[DEBUG] isEmbed check:', { res, path, hash, href: window.location.href });
console.log('[DEBUG] isEmbed check:', { res, path, hash, href: loc });
return res;
};
const getEmbedView = () => {
const fullPath = window.location.pathname + window.location.hash;
const loc = location(); // Reactive dependency
const url = new URL(loc);
const fullPath = url.pathname + url.hash;
let view = null;
if (fullPath.includes('/notes')) view = 'embed_notes';
else if (fullPath.includes('/quick-add')) view = 'embed_quick_add';
@@ -101,10 +114,12 @@ const App: Component = () => {
<Suspense fallback={<div class="flex items-center justify-center h-full"><div class="animate-spin rounded-full h-8 w-8 border-b-2 border-primary"></div></div>}>
<Show when={getEmbedView() === 'embed_notes'}>
{(() => {
const searchParams = new URLSearchParams(window.location.search);
const noteIdFromUrl = searchParams.get('noteId');
const [selectedNoteId, setSelectedNoteId] = createSignal<string | null>(noteIdFromUrl);
return <NotepadView selectedNoteId={selectedNoteId()} setSelectedNoteId={setSelectedNoteId} hideNavigation={!!noteIdFromUrl} />;
const noteIdFromUrl = createMemo(() => {
const params = new URLSearchParams(new URL(location()).search);
return params.get('noteId');
});
console.log('[DEBUG App] Rendering embed/notes context. noteId trace:', noteIdFromUrl());
return <NotepadView selectedNoteId={noteIdFromUrl()} setSelectedNoteId={() => { }} hideNavigation={!!noteIdFromUrl()} />;
})()}
</Show>
<Show when={getEmbedView() === 'embed_quick_add'}>