Open PWA on last opened page
This commit is contained in:
parent
bd77f2932c
commit
f22b9c4a1f
@ -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() {
|
||||
|
@ -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 (
|
||||
<div id="sb-top" className={synced ? undefined : "sb-sync-error"}>
|
||||
<div id="sb-top" className={syncFailures > 1 ? "sb-sync-error" : undefined}>
|
||||
{lhs}
|
||||
<div className="main">
|
||||
<div className="inner">
|
||||
|
@ -178,7 +178,7 @@ export class MainUI {
|
||||
<TopBar
|
||||
pageName={viewState.currentPage}
|
||||
notifications={viewState.notifications}
|
||||
synced={viewState.synced}
|
||||
syncFailures={viewState.syncFailures}
|
||||
unsavedChanges={viewState.unsavedChanges}
|
||||
isLoading={viewState.isLoading}
|
||||
vimMode={viewState.uiOptions.vimMode}
|
||||
|
@ -9,7 +9,7 @@
|
||||
}
|
||||
],
|
||||
"capture_links": "new-client",
|
||||
"start_url": "/",
|
||||
"start_url": "/#boot",
|
||||
"display": "standalone",
|
||||
"scope": "/",
|
||||
"theme_color": "#e1e1e1",
|
||||
|
@ -37,7 +37,7 @@ export default function reducer(
|
||||
case "sync-change":
|
||||
return {
|
||||
...state,
|
||||
synced: action.synced,
|
||||
syncFailures: action.syncSuccess ? 0 : state.syncFailures + 1,
|
||||
};
|
||||
case "start-navigate":
|
||||
return {
|
||||
|
@ -52,7 +52,7 @@ export type AppViewState = {
|
||||
showCommandPalette: boolean;
|
||||
showCommandPaletteContext?: string;
|
||||
unsavedChanges: boolean;
|
||||
synced: boolean;
|
||||
syncFailures: number; // Reset everytime a sync succeeds
|
||||
progressPerc?: number;
|
||||
panels: { [key: string]: PanelConfig };
|
||||
allPages: PageMeta[];
|
||||
@ -91,7 +91,7 @@ export const initialViewState: AppViewState = {
|
||||
showPageNavigator: false,
|
||||
showCommandPalette: false,
|
||||
unsavedChanges: false,
|
||||
synced: true,
|
||||
syncFailures: 0,
|
||||
uiOptions: {
|
||||
vimMode: false,
|
||||
darkMode: false,
|
||||
@ -124,7 +124,7 @@ export type Action =
|
||||
| { type: "pages-listed"; pages: PageMeta[] }
|
||||
| { type: "page-changed" }
|
||||
| { type: "page-saved" }
|
||||
| { type: "sync-change"; synced: boolean }
|
||||
| { type: "sync-change"; syncSuccess: boolean }
|
||||
| { type: "start-navigate" }
|
||||
| { type: "stop-navigate" }
|
||||
| {
|
||||
|
@ -7,7 +7,9 @@ release.
|
||||
* Sync improvements:
|
||||
* Now syncing the currently open page every 5s with the server
|
||||
* Now more instantly syncing indirectly updated pages, e.g. when checking off tasks in a query
|
||||
* Less aggressive "you're offline" signaling (now only showing yellow bar after 2 failed sync attempts)
|
||||
* New `/page-template` slash command to apply (insert) a page [[🔌 Core/Templates|template]] at the current location
|
||||
* When the PWA starts, it will now send you back to the last opened page instead of the index page (you may have to reinstall the PWA for this change to take effect).
|
||||
* [[Markdown/Syntax Highlighting]] for HTML
|
||||
* [[Frontmatter]] attributes starting with `$` are now indexed again
|
||||
* Various heavy-weight commands (such as {[Space: Reindex]} and {[Directives: Update Entire Space]}) now use an internal message queue, allowing to continue the processing even when interrupted or crashing.
|
||||
|
Loading…
Reference in New Issue
Block a user