split logic
This commit is contained in:
parent
03499a8800
commit
2779c5e608
@ -16,6 +16,19 @@ let currentStyle = defaultStyle;
|
|||||||
|
|
||||||
const api : ControllerAPI = new ControllerAPI();
|
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() {
|
async function main() {
|
||||||
// init navbar
|
// init navbar
|
||||||
const navbar = new Navbar();
|
const navbar = new Navbar();
|
||||||
@ -23,14 +36,9 @@ async function main() {
|
|||||||
document.body.innerHTML = "<div id='app'></div>" + navbar.build();
|
document.body.innerHTML = "<div id='app'></div>" + navbar.build();
|
||||||
|
|
||||||
if (await api.isAuthenticated()) {
|
if (await api.isAuthenticated()) {
|
||||||
console.log("User is authenticated");
|
await authInit();
|
||||||
const newsFeed = await api.getNews(true) as NewsFeed;
|
|
||||||
const appElement = document.getElementById("app");
|
|
||||||
if (appElement)
|
|
||||||
appElement.innerHTML = newsFeed.build();
|
|
||||||
} else {
|
} else {
|
||||||
console.log("User is not authenticated");
|
await logInInit();
|
||||||
// Load the auth page
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user