Start invitation; notification; add profile avatar in me

This commit is contained in:
2024-01-15 16:29:18 +01:00
parent 11392c22c4
commit cdb4dab47a
9 changed files with 300 additions and 35 deletions

View File

@ -10,7 +10,8 @@ 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) {
//console.log(client.notice.data["online"].length);
if (client.notice.data["online"].length > 0) {
clearInterval(checkInterval);
resolve();
}
@ -23,10 +24,11 @@ export default class extends AbstractView {
let logged = await client.isAuthentificate();
let profiles = await client.profiles.all();
if (client.notice == undefined || client.notice.online_users == undefined)
//console.log(client.notice.data);
if (client.notice.data == undefined || client.notice.data["online"] == undefined)
return console.log("Error");
await client.notice.getOnlineUser();
//await client.notice.getOnlineUser();
await this.wait_get_online_users();
client.notice.rewrite_usernames = this.rewrite_usernames;
@ -64,7 +66,7 @@ export default class extends AbstractView {
username.setAttribute('data-link', '');
username.id = `username${user.id}`
username.href = `/profiles/${user.id}`;
username.style.color = client.notice.online_users[user.id] !== undefined ? "green" : "red";
username.style.color = client.notice.data["online"].includes(user.id.toString()) ? "green" : "red";
username.appendChild(document.createTextNode(user.username));
new_user.appendChild(username);
@ -134,7 +136,7 @@ export default class extends AbstractView {
profiles.filter(user => user.username.toLowerCase().startsWith(search) == true).forEach((user) => {
let username = document.getElementById(`username${user.id}`);
if (username !== null)
username.style.color = client.notice.online_users[user.id] !== undefined ? "green" : "red";
username.style.color = client.notice.data["online"].includes(user.id.toString()) ? "green" : "red";
});
}
@ -194,15 +196,7 @@ export default class extends AbstractView {
// Scroll to the bottom of messages
messages.scrollTop = messages.scrollHeight;
// Button to send invite to play
let invite = document.getElementById("invite") || document.createElement("button");
invite.id = "invite";
invite.innerText = "invite";
invite.onclick = async () => {
await client.notice.sendInvite(client.me.id,
client.channels.channel.members_id.filter(id => id !== client.me.id));
};
chat.appendChild(invite);
this.display_invite(chat);
}
@ -264,6 +258,20 @@ export default class extends AbstractView {
return members
}
async display_invite(chat, profiles) {
// Button to send invite to play
let invite = document.getElementById("invite") || document.createElement("button");
invite.id = "invite";
invite.innerText = "invite";
invite.onclick = async () => {
await client.notice.sendInvite(client.me.id,
client.channels.channel.members_id.filter(id => id !== client.me.id));
};
chat.appendChild(invite);
}
async hide_chat() {
let closes = ["chat", "invite"]