Starting popup notice

This commit is contained in:
2024-01-14 15:40:20 +01:00
parent a254e5a0c2
commit a085fcd92b
9 changed files with 60 additions and 17 deletions

View File

@ -11,11 +11,24 @@ export default class extends AbstractAuthentificateView
async postInit()
{
document.getElementById("save-account-button").onclick = this.save_account;
document.getElementById("delete-account-button").onclick = this.delete_account;
document.getElementById("save-profile-button").onclick = this.save_profile;
this.display_avatar();
document.getElementById("save-account-button").onclick = () => this.save_account();
document.getElementById("delete-account-button").onclick = () => this.delete_account();
document.getElementById("save-profile-button").onclick = () => this.save_profile();
}
async display_avatar() {
let profile = await client.profiles.getProfile(client.me.id);
if (profile !== undefined || profile !== null) {
if (document.getElementById("avatar") != undefined)
document.getElementById("avatar").remove();
let avatar = document.createElement("img");
avatar.id = "avatar";
avatar.src = profile.avatar_url;
document.getElementsByClassName("avatar")[0].appendChild(avatar);
}
}
async delete_account()
{
let current_password = document.getElementById("current_password-input").value;
@ -68,6 +81,7 @@ export default class extends AbstractAuthentificateView
let form_data = new FormData();
form_data.append("file", avatar.files[0]);
await client.me.change_avatar(form_data);
this.display_avatar();
}
document.getElementById("save-profile").innerHTML = "Saved";
}
@ -78,6 +92,8 @@ export default class extends AbstractAuthentificateView
<link rel="stylesheet" href="/static/css/me.css">
<h1>ME</h1>
<div id="main">
<div class="avatar">
</div>
<div class="account">
<h3>Account</h3>
<input type="text" placeholder="username" id="username-input" text=${client.me.username}>

View File

@ -10,7 +10,10 @@ export default class extends AbstractView {
async wait_get_online_users() {
return new Promise((resolve) => {
const checkInterval = setInterval(() => {
if (Object.keys(client.notice.online_users).length > 0) {
if (client.notice !== undefined &&
client.notice.online_users !== undefined &&
Object.keys(client.notice.online_users).length > 0) {
clearInterval(checkInterval);
resolve();
}