From 0626faae7feffab4cf2c55c5ca05921728d65f28 Mon Sep 17 00:00:00 2001 From: starnakin Date: Thu, 21 Dec 2023 00:04:48 +0100 Subject: [PATCH] core: edit renderView engine to display 404 error on not found page --- frontend/static/js/index.js | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/frontend/static/js/index.js b/frontend/static/js/index.js index 346eacb..f81cf96 100644 --- a/frontend/static/js/index.js +++ b/frontend/static/js/index.js @@ -35,6 +35,19 @@ const navigateTo = async (uri) => { history.pushState(null, null, uri); }; +async function renderView(view) +{ + let content = await view.getHtml(); + if (content == null) + return 1; + + view.setTitle(); + document.querySelector("#app").innerHTML = content + + if (await view.postInit()) + renderView(new PageNotFoundView()); +} + const router = async (uri) => { const routes = [ { path: "/", view: Dashboard }, @@ -80,14 +93,7 @@ const router = async (uri) => { lastView = view; await client.isAuthentificate(); - let content = await view.getHtml(); - if (content == null) - return 1; - - view.setTitle(); - document.querySelector("#app").innerHTML = content - - await view.postInit(); + renderView(view); return 0; };