opti: do not execute postInit if getHtml is null

This commit is contained in:
starnakin 2023-11-29 16:18:54 +01:00
parent d5e692449b
commit 07d06253ba
3 changed files with 8 additions and 9 deletions

View File

@ -59,7 +59,11 @@ const router = async () => {
}
const view = new match.route.view(getParams(match));
document.querySelector("#app").innerHTML = await view.getHtml();
let content = await view.getHtml();
if (content == null)
return;
document.querySelector("#app").innerHTML = content
await view.postInit();
};

View File

@ -35,9 +35,7 @@ export default class extends AbstractView {
async postInit()
{
let login_button = document.getElementById("button")
if (login_button != null)
login_button.onclick = login;
document.getElementById("button").onclick = login;
}
async getHtml() {

View File

@ -30,14 +30,11 @@ export default class extends AbstractView {
async postInit()
{
let register_button = document.getElementById("button")
if (register_button != null)
register_button.onclick = register;
document.getElementById("button").onclick = register;
}
async getHtml() {
if (client.isAuthentificate())
if (await client.isAuthentificate())
{
navigateTo("/home")
return;