diff --git a/src/App.tsx b/src/App.tsx
index ffc3f4d..c15edc4 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -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 = () => {
2. Creating Notes Programmatically (API): Before embedding, a sister app can create a Note via PocketBase API to retrieve a new
noteId. By default, notes should have an array of tags and a
- title.title.
+
Using the PocketBase JS SDK:
-const record = await pb.collection('notes').create({
+const record = await pb.collection('TasGrid_Notes').create({
title: "Sister App Payload",
content: "<p>Initial content here...</p>",
tags: ["sister_app_export"],
@@ -178,7 +179,7 @@ const newNoteId = record.id;
Using standard REST API (fetch):
-const res = await fetch('https://pocketbase.ccllc.pro/api/collections/notes/records', {
+const res = await fetch('https://pocketbase.ccllc.pro/api/collections/TasGrid_Notes/records', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
@@ -197,14 +198,24 @@ const newNoteId = data.id;
3. Authentication Protocol:
The parent application must send a postMessage to the iframe immediately after the
- iframe loads (or whenever auth state changes).
+ iframe loads (or whenever auth state changes). Since iframes reset their internal state on
+ navigation,
+ you should always sync auth on the onload event.
+ Example using vanilla JS:
-iframe.contentWindow.postMessage({
- type: "TASGRID_AUTH",
- token: "YOUR_POCKETBASE_TOKEN",
- user: { /* optional PB user record */ }
-}, "*");
+// 1. Define sync function
+function syncAuth(iframe) {
+ iframe.contentWindow.postMessage({
+ type: "TASGRID_AUTH",
+ token: pb.authStore.token,
+ user: pb.authStore.model
+ }, "*");
+}
+
+// 2. Attach to iframe (either in HTML or via JS)
+// <iframe onload="syncAuth(this)" src="..."></iframe>
+
4. Responsiveness:
Both routes are designed to be fluid. Ensure your iframe container has defined dimensions; the
@@ -221,7 +232,7 @@ iframe.contentWindow.postMessage({
Notes Embed
/embed/notes
-
+
/embed/quick-add
This note was created automatically via the API script!
", tags: ["api_generated"],