merge with Chatte
This commit is contained in:
@ -7,6 +7,12 @@ class Channels {
|
||||
}
|
||||
|
||||
async createChannel(users_id, reload) {
|
||||
|
||||
users_id.forEach(user_id => {
|
||||
if (user_id == null)
|
||||
return console.log("createChannel error, null id;");
|
||||
});
|
||||
|
||||
let response = await this.client._post("/api/chat/", {
|
||||
users_id:users_id
|
||||
});
|
||||
|
@ -10,11 +10,12 @@ export default class extends AbstractView {
|
||||
async postInit() {
|
||||
|
||||
let search = document.getElementById("input_user");
|
||||
search.addEventListener("input", this.users)
|
||||
search.oninput = this.users;
|
||||
|
||||
let chat_input = document.getElementById("input_chat");
|
||||
//chat_input.addEventListener("keydown", this.chat_manager)
|
||||
|
||||
this.last_add_chat = undefined;
|
||||
this.users();
|
||||
this.chat();
|
||||
|
||||
@ -31,6 +32,12 @@ export default class extends AbstractView {
|
||||
list_users.innerHTML = "";
|
||||
|
||||
users.filter(user => user.username.toLowerCase().startsWith(search) == true).forEach((user) => {
|
||||
|
||||
if (user.user_id == null) {
|
||||
console.log("list User one with id null;");
|
||||
return;
|
||||
}
|
||||
|
||||
var new_user = document.createElement("li");
|
||||
|
||||
// username
|
||||
@ -46,24 +53,29 @@ export default class extends AbstractView {
|
||||
if (logged && client.me.user_id != user.user_id) {
|
||||
let add_chat = document.createElement("a");
|
||||
add_chat.id = "add_chat_off";
|
||||
add_chat.addEventListener("click", async () => {
|
||||
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)
|
||||
client.channel = undefined;
|
||||
});
|
||||
|
||||
if (client.channel == undefined)
|
||||
if (client.channel == undefined) {
|
||||
add_chat.id = "add_chat_off";
|
||||
this.last_add_chat = undefined;
|
||||
return this.hideChat();
|
||||
}
|
||||
|
||||
client.channel.disconnect();
|
||||
}
|
||||
|
||||
client.channel = await client.channels.createChannel([client.me.user_id , user.user_id], this.chat);
|
||||
this.chat();
|
||||
if (this.last_add_chat != undefined)
|
||||
this.last_add_chat.id = "add_chat_off";
|
||||
this.last_add_chat = add_chat;
|
||||
add_chat.id = "add_chat_on";
|
||||
});
|
||||
};
|
||||
add_chat.appendChild(document.createTextNode("Chat"));
|
||||
new_user.appendChild(add_chat);
|
||||
|
||||
|
Reference in New Issue
Block a user