split logic
This commit is contained in:
parent
03499a8800
commit
2779c5e608
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user