split logic

This commit is contained in:
FullGreaM 2026-04-26 22:51:44 +03:00
parent 03499a8800
commit 2779c5e608

View File

@ -16,6 +16,19 @@ let currentStyle = defaultStyle;
const api : ControllerAPI = new ControllerAPI();
async function authInit() {
console.log("User is authenticated");
const newsFeed = await api.getNews(true) as NewsFeed;
const appElement = document.getElementById("app");
if (appElement)
appElement.innerHTML = newsFeed.build();
}
async function logInInit () {
console.log("User is not authenticated");
// Load the auth page
}
async function main() {
// init navbar
const navbar = new Navbar();
@ -23,14 +36,9 @@ async function main() {
document.body.innerHTML = "<div id='app'></div>" + navbar.build();
if (await api.isAuthenticated()) {
console.log("User is authenticated");
const newsFeed = await api.getNews(true) as NewsFeed;
const appElement = document.getElementById("app");
if (appElement)
appElement.innerHTML = newsFeed.build();
await authInit();
} else {
console.log("User is not authenticated");
// Load the auth page
await logInInit();
}
}