From 386c5ab916fc329bb0887273d72d069c277444d6 Mon Sep 17 00:00:00 2001 From: Zef Hemel Date: Thu, 5 Oct 2023 18:24:12 +0200 Subject: [PATCH] Minor page load fixes --- common/spaces/evented_space_primitives.ts | 1 - common/spaces/http_space_primitives.ts | 3 +++ web/client.ts | 17 ++++++++++++----- web/editor_ui.tsx | 1 - 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/common/spaces/evented_space_primitives.ts b/common/spaces/evented_space_primitives.ts index 4926308..6168331 100644 --- a/common/spaces/evented_space_primitives.ts +++ b/common/spaces/evented_space_primitives.ts @@ -31,7 +31,6 @@ export class EventedSpacePrimitives implements SpacePrimitives { // Avoid race conditions return newFileList; } - // console.log("HEREEREEEREEREE"); this.alreadyFetching = true; const deletedFiles = new Set(Object.keys(this.spaceSnapshot)); for (const meta of newFileList) { diff --git a/common/spaces/http_space_primitives.ts b/common/spaces/http_space_primitives.ts index 07bf140..98fdf74 100644 --- a/common/spaces/http_space_primitives.ts +++ b/common/spaces/http_space_primitives.ts @@ -151,6 +151,9 @@ export class HttpSpacePrimitives implements SpacePrimitives { if (res.status === 404) { throw new Error(`Not found`); } + if (!res.ok) { + throw new Error(`Failed to get file meta: ${res.statusText}`); + } return this.responseToMeta(name, res); } diff --git a/web/client.ts b/web/client.ts index 7275a4c..7a3cb69 100644 --- a/web/client.ts +++ b/web/client.ts @@ -764,11 +764,18 @@ export class Client { meta: { name: pageName, lastModified: 0, perm: "rw" } as PageMeta, }; } else { - console.error("Could not load page", pageName, e); - doc = { - text: `**ERROR**: ${e.message}`, - meta: { name: pageName, lastModified: 0, perm: "ro" } as PageMeta, - }; + this.flashNotification( + `Could not load page ${pageName}: ${e.message}`, + "error", + ); + if (previousPage) { + this.ui.viewDispatch({ + type: "page-loading", + name: previousPage, + }); + } + + return false; } } diff --git a/web/editor_ui.tsx b/web/editor_ui.tsx index 1ef53b9..fe3b592 100644 --- a/web/editor_ui.tsx +++ b/web/editor_ui.tsx @@ -19,7 +19,6 @@ import { import type { Client } from "./client.ts"; import { Panel } from "./components/panel.tsx"; import { h } from "./deps.ts"; -import { async } from "https://cdn.skypack.dev/-/regenerator-runtime@v0.13.9-4Dxus9nU31cBsHxnWq2H/dist=es2020,mode=imports/optimized/regenerator-runtime.js"; import { sleep } from "$sb/lib/async.ts"; export class MainUI {