core: use postinit status code
This commit is contained in:
@ -12,7 +12,7 @@ export default class extends AbstractView {
|
||||
let profile = await client.profiles.getProfile(this.user_id);
|
||||
|
||||
if (profile === null)
|
||||
return 1;
|
||||
return 404;
|
||||
|
||||
this.profile = await client.profiles.getProfile(this.user_id);
|
||||
this.info = document.getElementById("info");
|
||||
@ -36,6 +36,9 @@ export default class extends AbstractView {
|
||||
|
||||
async blockButton() {
|
||||
// Block option
|
||||
if (await client.isAuthentificate() === false)
|
||||
return;
|
||||
|
||||
if (client.me.user_id != this.user_id) {
|
||||
let block = document.getElementById("block") || document.createElement("a");
|
||||
block.id = "block";
|
||||
|
@ -16,24 +16,25 @@ export default class extends AbstractView {
|
||||
//chat_input.addEventListener("keydown", this.chat_manager)
|
||||
|
||||
this.last_add_chat = undefined;
|
||||
this.users();
|
||||
this.chat();
|
||||
|
||||
let logged = await client.isAuthentificate();
|
||||
let profiles = await client.profiles.all();
|
||||
|
||||
this.users(logged, profiles);
|
||||
this.chat(logged, profiles);
|
||||
|
||||
}
|
||||
|
||||
async users() {
|
||||
async users(logged, profiles) {
|
||||
|
||||
let search = document.getElementById("input_user").value.toLowerCase();
|
||||
|
||||
let logged = await client.isAuthentificate();
|
||||
|
||||
let users = await client.profiles.all();
|
||||
let list_users = document.getElementById('list_users');
|
||||
list_users.innerHTML = "";
|
||||
|
||||
users.filter(user => user.username.toLowerCase().startsWith(search) == true).forEach((user) => {
|
||||
profiles.filter(user => user.username.toLowerCase().startsWith(search) == true).forEach((user) => {
|
||||
|
||||
if (user.user_id == null) {
|
||||
if (user.id == null) {
|
||||
console.log("list User one with id null;");
|
||||
return;
|
||||
}
|
||||
@ -42,7 +43,7 @@ export default class extends AbstractView {
|
||||
|
||||
// username
|
||||
let username = document.createElement("a");
|
||||
username.href = `/profiles/${user.user_id}`;
|
||||
username.href = `/profiles/${user.id}`;
|
||||
username.appendChild(document.createTextNode(user.username));
|
||||
new_user.appendChild(username);
|
||||
|
||||
@ -50,13 +51,13 @@ export default class extends AbstractView {
|
||||
new_user.appendChild(document.createTextNode(" "));
|
||||
|
||||
// chat
|
||||
if (logged && client.me.user_id != user.user_id) {
|
||||
if (logged && client.me.id != user.id) {
|
||||
let add_chat = document.createElement("a");
|
||||
add_chat.id = "add_chat_off";
|
||||
add_chat.onclick = async () => {
|
||||
if (client.channel != undefined) {
|
||||
client.channel.members_id.forEach((member_id) => {
|
||||
if (member_id == user.user_id)
|
||||
if (member_id == user.id)
|
||||
client.channel = undefined;
|
||||
});
|
||||
|
||||
@ -69,7 +70,7 @@ export default class extends AbstractView {
|
||||
client.channel.disconnect();
|
||||
}
|
||||
|
||||
client.channel = await client.channels.createChannel([client.me.user_id , user.user_id], this.chat);
|
||||
client.channel = await client.channels.createChannel([client.me.id , user.id], this.chat);
|
||||
this.chat();
|
||||
if (this.last_add_chat != undefined)
|
||||
this.last_add_chat.id = "add_chat_off";
|
||||
@ -98,10 +99,8 @@ export default class extends AbstractView {
|
||||
|
||||
}
|
||||
|
||||
async chat() {
|
||||
async chat(logged, profiles) {
|
||||
|
||||
let users = await client.profiles.all();
|
||||
let logged = await client.isAuthentificate();
|
||||
/*let reload = document.getElementById("messages");
|
||||
if (reload != null)
|
||||
reload.remove();*/
|
||||
@ -139,7 +138,7 @@ export default class extends AbstractView {
|
||||
if (messages.children[i] == null || message.content != messages.children[i].innerText) {
|
||||
let text = document.createElement("p");
|
||||
text.appendChild(document.createTextNode(message.content));
|
||||
if (message.author_id == client.me.user_id)
|
||||
if (message.author_id == client.me)
|
||||
text.id = "you";
|
||||
else
|
||||
text.id = "other";
|
||||
@ -166,8 +165,8 @@ export default class extends AbstractView {
|
||||
|
||||
let receivers_id = [];
|
||||
client.channel.members_id.forEach((member_id) => {
|
||||
if (member_id != client.me.user_id)
|
||||
receivers_id.push(users.filter(user => user.user_id == member_id)[0].user_id);
|
||||
if (member_id != client.me)
|
||||
receivers_id.push(profiles.filter(user => user.id == member_id)[0].user_id);
|
||||
});
|
||||
await client.channel.sendMessageChannel(chat_text, receivers_id)
|
||||
|
||||
@ -182,10 +181,10 @@ export default class extends AbstractView {
|
||||
members.id = "members";
|
||||
let usernames = "";
|
||||
client.channel.members_id.forEach((member_id) => {
|
||||
if (member_id != client.me.user_id) {
|
||||
if (member_id != client.me) {
|
||||
if (usernames.length > 0)
|
||||
usernames += ", ";
|
||||
usernames += (users.filter(user => user.user_id == member_id)[0].username);
|
||||
usernames += (profiles.filter(user => user.id == member_id)[0].username);
|
||||
}
|
||||
});
|
||||
members.appendChild(document.createTextNode(usernames));
|
||||
|
@ -41,7 +41,7 @@ export default class extends AbstractAuthentifiedView
|
||||
this.tournament = await client.tournaments.getTournament(this.id);
|
||||
|
||||
if (this.tournament === null)
|
||||
return 1;
|
||||
return 404;
|
||||
|
||||
this.tournament.join(this.receive.bind(this), this.ondisconnect.bind(this));
|
||||
|
||||
|
Reference in New Issue
Block a user