core: use postinit status code

This commit is contained in:
2024-01-08 20:57:43 +01:00
parent 6f9903e309
commit 476ed0b833
12 changed files with 87 additions and 89 deletions

View File

@ -6,7 +6,8 @@ import Search from "./views/Search.js";
import HomeView from "./views/HomeView.js";
import RegisterView from "./views/accounts/RegisterView.js";
import LogoutView from "./views/accounts/LogoutView.js";
import GameView from "./views/Game.js"
import GameOfflineView from "./views/GameOfflineView.js";
import GameView from "./views/GameView.js";
import PageNotFoundView from './views/PageNotFoundView.js'
@ -47,11 +48,16 @@ async function renderView(view)
view.setTitle();
document.querySelector("#app").innerHTML = content
if (await view.postInit())
let error_code = await view.postInit();
if (error_code === 404)
renderView(new PageNotFoundView());
else if (error_code === 403)
this._client._update_logged(false);
}
const router = async (uri) => {
const router = async(uri) => {
const routes = [
{ path: "/", view: Dashboard },
{ path: "/profiles/:id", view: ProfilePageView },
@ -65,7 +71,8 @@ const router = async (uri) => {
{ path: "/home", view: HomeView },
{ path: "/me", view: MeView },
{ path: "/matchmaking", view: MatchMakingView },
{ path: "/game/offline", view: GameView },
{ path: "/games/offline", view: GameOfflineView },
{ path: "/games/:id", view: GameView },
];
// Test each route for potential match
@ -98,8 +105,9 @@ const router = async (uri) => {
lastView = view;
await client.isAuthentificate();
renderView(view);
if (await renderView(view))
return 1;
return 0;
};