Navigator refactor (#648)

Navigation refactor
This commit is contained in:
Zef Hemel
2024-01-24 11:58:33 +01:00
committed by GitHub
parent 9fa52e43e0
commit aaacec6d61
25 changed files with 360 additions and 263 deletions
+6 -3
View File
@@ -13,6 +13,7 @@ import {
import { SysCallMapping } from "../../plugos/system.ts";
import type { FilterOption } from "../types.ts";
import { UploadFile } from "../../plug-api/types.ts";
import { PageRef } from "$sb/lib/page.ts";
export function editorSyscalls(client: Client): SysCallMapping {
const syscalls: SysCallMapping = {
@@ -33,12 +34,14 @@ export function editorSyscalls(client: Client): SysCallMapping {
},
"editor.navigate": async (
_ctx,
name: string,
pos: number | string,
pageRef: PageRef | string,
replaceState = false,
newWindow = false,
) => {
await client.navigate(name, pos, replaceState, newWindow);
if (typeof pageRef === "string") {
pageRef = { page: pageRef };
}
await client.navigate(pageRef, replaceState, newWindow);
},
"editor.reloadPage": async () => {
await client.reloadPage();
+2 -2
View File
@@ -23,10 +23,10 @@ export function spaceSyscalls(editor: Client): SysCallMapping {
"space.deletePage": async (_ctx, name: string) => {
// If we're deleting the current page, navigate to the index page
if (editor.currentPage === name) {
await editor.navigate("");
await editor.navigate({ page: "" });
}
// Remove page from open pages in editor
editor.openPages.openPages.delete(name);
// editor.openPages.openPages.delete(name);
console.log("Deleting page");
await editor.space.deletePage(name);
},