From d5e692449b44a324df7579c02107b7704a5b15c4 Mon Sep 17 00:00:00 2001 From: starnakin Date: Wed, 29 Nov 2023 16:10:55 +0100 Subject: [PATCH] fix: move code to not render html when not needed --- frontend/static/js/views/accounts/LoginView.js | 10 ++++++---- frontend/static/js/views/accounts/RegisterView.js | 11 +++++++---- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/frontend/static/js/views/accounts/LoginView.js b/frontend/static/js/views/accounts/LoginView.js index b9a6621..b751328 100644 --- a/frontend/static/js/views/accounts/LoginView.js +++ b/frontend/static/js/views/accounts/LoginView.js @@ -35,15 +35,17 @@ export default class extends AbstractView { async postInit() { + let login_button = document.getElementById("button") + if (login_button != null) + login_button.onclick = login; + } + + async getHtml() { if (await client.isAuthentificate()) { navigateTo("/home") return; } - document.getElementById("button").onclick = login; - } - - async getHtml() { return `
diff --git a/frontend/static/js/views/accounts/RegisterView.js b/frontend/static/js/views/accounts/RegisterView.js index 1616050..7fe2cef 100644 --- a/frontend/static/js/views/accounts/RegisterView.js +++ b/frontend/static/js/views/accounts/RegisterView.js @@ -30,15 +30,18 @@ export default class extends AbstractView { async postInit() { + let register_button = document.getElementById("button") + if (register_button != null) + register_button.onclick = register; + + } + + async getHtml() { if (client.isAuthentificate()) { navigateTo("/home") return; } - document.getElementById("button").onclick = register; - } - - async getHtml() { return `