diff --git a/web/client.ts b/web/client.ts index 1da29f69..c76e03e3 100644 --- a/web/client.ts +++ b/web/client.ts @@ -34,6 +34,7 @@ import { createEditorState } from "./editor_state.ts"; import { OpenPages } from "./open_pages.ts"; import { MainUI } from "./editor_ui.tsx"; import { DexieMQ } from "../plugos/lib/mq.dexie.ts"; +import { async } from "https://cdn.skypack.dev/-/regenerator-runtime@v0.13.9-4Dxus9nU31cBsHxnWq2H/dist=es2020,mode=imports/optimized/regenerator-runtime.js"; const frontMatterRegex = /^---\n(([^\n]|\n)*?)---\n/; const autoSaveInterval = 1000; @@ -222,10 +223,10 @@ export class Client { // Reset for next sync cycle this.system.plugsUpdated = false; - this.ui.viewDispatch({ type: "sync-change", synced: true }); + this.ui.viewDispatch({ type: "sync-change", syncSuccess: true }); }); this.eventHook.addLocalListener("sync:error", (_name) => { - this.ui.viewDispatch({ type: "sync-change", synced: false }); + this.ui.viewDispatch({ type: "sync-change", syncSuccess: false }); }); this.eventHook.addLocalListener("sync:conflict", (name) => { this.flashNotification( @@ -303,7 +304,18 @@ export class Client { scrollIntoView: true, }); } + await this.kvStore.set("lastOpenedPage", pageName); }); + + if (location.hash === "#boot") { + (async () => { + // Cold start PWA load + const lastPage = await this.kvStore.get("lastOpenedPage"); + if (lastPage) { + await this.navigate(lastPage); + } + })().catch(console.error); + } } initSpace() { diff --git a/web/components/top_bar.tsx b/web/components/top_bar.tsx index 09b65291..8a815cb2 100644 --- a/web/components/top_bar.tsx +++ b/web/components/top_bar.tsx @@ -19,7 +19,7 @@ export type ActionButton = { export function TopBar({ pageName, unsavedChanges, - synced, + syncFailures, isLoading, notifications, onRename, @@ -33,7 +33,7 @@ export function TopBar({ }: { pageName?: string; unsavedChanges: boolean; - synced: boolean; + syncFailures: number; isLoading: boolean; notifications: Notification[]; darkMode: boolean; @@ -78,7 +78,7 @@ export function TopBar({ }, []); return ( -
+
1 ? "sb-sync-error" : undefined}> {lhs}
diff --git a/web/editor_ui.tsx b/web/editor_ui.tsx index e0a18b82..a088c318 100644 --- a/web/editor_ui.tsx +++ b/web/editor_ui.tsx @@ -178,7 +178,7 @@ export class MainUI {