Compare commits

..

No commits in common. "8e0514514bcbb0c3afdc9f7bee3cc66bb8dc757f" and "5ba432e9fdf4768c649df5dc4d615ce577b55ae2" have entirely different histories.

4 changed files with 10 additions and 25 deletions

View File

@ -19,10 +19,6 @@ class Profile
async init(user_id)
{
let response = await this.client._get(`/api/profiles/${user_id}`);
if (response.status === 404)
return 1;
let response_data = await response.json();
this.user_id = response_data.user_id;

View File

@ -28,8 +28,7 @@ class Profiles
async getProfile(user_id)
{
let profile = new Profile(this.client);
if (await profile.init(user_id))
return null;
await profile.init(user_id);
return profile;
}

View File

@ -35,19 +35,6 @@ const navigateTo = async (uri) => {
history.pushState(null, null, uri);
};
async function renderView(view)
{
let content = await view.getHtml();
if (content == null)
return 1;
view.setTitle();
document.querySelector("#app").innerHTML = content
if (await view.postInit())
renderView(new PageNotFoundView());
}
const router = async (uri) => {
const routes = [
{ path: "/", view: Dashboard },
@ -93,7 +80,14 @@ const router = async (uri) => {
lastView = view;
await client.isAuthentificate();
renderView(view);
let content = await view.getHtml();
if (content == null)
return 1;
view.setTitle();
document.querySelector("#app").innerHTML = content
await view.postInit();
return 0;
};

View File

@ -10,10 +10,6 @@ export default class extends AbstractView {
async postInit()
{
let profile = await client.profiles.getProfile(this.user_id);
if (profile === null)
return 1;
let info = document.getElementById("info");
// Username
@ -22,7 +18,7 @@ export default class extends AbstractView {
username.appendChild(document.createTextNode(profile.username));
info.appendChild(username);
info.appendChild(document.createElement("br"));
info.appendChild(document.createElement("br"));
// Avatar
let avatar = document.createElement("img");