From 533f0c04f9804892e65f1c2877dbc663f6f51d62 Mon Sep 17 00:00:00 2001 From: Xamora Date: Mon, 13 May 2024 16:44:20 +0200 Subject: [PATCH] Search patch and old notification remove --- frontend/static/js/views/Search.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/frontend/static/js/views/Search.js b/frontend/static/js/views/Search.js index 4533165..76e5441 100644 --- a/frontend/static/js/views/Search.js +++ b/frontend/static/js/views/Search.js @@ -25,13 +25,13 @@ export default class extends AbstractView { let profiles = await client.profiles.all(); //console.log(client.notice.data); - if (client.notice.data == undefined || client.notice.data.online == undefined) - return console.log("Error"); + //if (client.notice.data == undefined || client.notice.data.online == undefined) + //return console.log("Error"); //await client.notice.getOnlineUser(); //await this.wait_get_online_users(); - client.notice.rewrite_usernames = this.rewrite_usernames; - client.notice.rewrite_invite = this.display_invite; + //client.notice.rewrite_usernames = this.rewrite_usernames; + //client.notice.rewrite_invite = this.display_invite; let search = document.getElementById("input_user"); if (search != undefined) @@ -54,7 +54,7 @@ export default class extends AbstractView { let list_users = document.getElementById('list_users'); list_users.innerHTML = ""; - profiles.filter(user => user.username.toLowerCase().startsWith(search) == true).forEach((user) => { + profiles.filter(user => user.username.toLowerCase().startsWith(search) == true).forEach(async (user) => { if (user.id == null) { console.log("list User one with id null;"); @@ -71,8 +71,14 @@ export default class extends AbstractView { if (logged && user.id == client.me.id) username.style.color = "green"; else { - let online = client.notice.data.online[user.id]; - username.style.color = online !== undefined ? online : "gray"; + let profile = await client.profiles.getProfileId(user.id); + let online = profile.online; + if (online == undefined) + username.style.color = "gray"; + if (online == true) + username.style.color = "green"; + else + username.style.color = "red"; } username.appendChild(document.createTextNode(user.username)); new_user.appendChild(username);