clean: respect es11
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import {Message} from "./message.js"
|
||||
import {Message} from "./message.js";
|
||||
|
||||
class Channel {
|
||||
constructor(client, channel_id, members_id, messages, reload) {
|
||||
@ -18,7 +18,7 @@ class Channel {
|
||||
|
||||
this.chatSocket = new WebSocket(url);
|
||||
this.chatSocket.onmessage = (event) =>{
|
||||
let data = JSON.parse(event.data)
|
||||
let data = JSON.parse(event.data);
|
||||
|
||||
this.messages.push(new Message(
|
||||
this.channel_id,
|
||||
@ -41,12 +41,12 @@ class Channel {
|
||||
let new_messages = [];
|
||||
|
||||
messages.forEach((message) => {
|
||||
message = message["fields"];
|
||||
message = message.fields;
|
||||
new_messages.push(new Message(
|
||||
message["channel_id"],
|
||||
message["author_id"],
|
||||
message["content"],
|
||||
message["time"],
|
||||
message.channel_id,
|
||||
message.author_id,
|
||||
message.content,
|
||||
message.time,
|
||||
));
|
||||
});
|
||||
|
||||
@ -80,4 +80,4 @@ class Channel {
|
||||
|
||||
}
|
||||
|
||||
export {Channel}
|
||||
export {Channel};
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {Channel} from "./channel.js"
|
||||
import {Channel} from "./channel.js";
|
||||
|
||||
class Channels {
|
||||
constructor(client) {
|
||||
@ -17,7 +17,7 @@ class Channels {
|
||||
|
||||
let data = await response.json();
|
||||
|
||||
let messages = undefined;
|
||||
let messages;
|
||||
if (response.status == 200)
|
||||
messages = data.messages;
|
||||
|
||||
@ -31,10 +31,9 @@ class Channels {
|
||||
});
|
||||
|
||||
let data = await response.json();
|
||||
console.log(response.status)
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export {Channels}
|
||||
export {Channels};
|
||||
|
@ -7,4 +7,4 @@ class Message {
|
||||
}
|
||||
}
|
||||
|
||||
export {Message}
|
||||
export {Message};
|
||||
|
@ -30,11 +30,11 @@ class Notice {
|
||||
console.log("receive_" + send.type + ": Function not found");
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
this.chatSocket.onopen = (event) => {
|
||||
this.getOnlineUser();
|
||||
this.ask_friend();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
async disconnect() {
|
||||
@ -60,8 +60,8 @@ class Notice {
|
||||
|
||||
async receive_accept_invite(send) {
|
||||
|
||||
this.data["invited"] = send.invites;
|
||||
let id_game = send["id_game"];
|
||||
this.data.invited = send.invites;
|
||||
let id_game = send.id_game;
|
||||
navigateTo("/game/" + id_game);
|
||||
|
||||
}
|
||||
@ -77,7 +77,7 @@ class Notice {
|
||||
}
|
||||
async receive_refuse_invite(send) {
|
||||
|
||||
this.data["invited"] = send.invites;
|
||||
this.data.invited = send.invites;
|
||||
|
||||
if (send.author_id == this.client.me.id) {
|
||||
if (this.rewrite_invite !== undefined)
|
||||
@ -123,10 +123,10 @@ class Notice {
|
||||
// Regarder qu'il est bien invité par l'auteur
|
||||
// Et qu'il n'est pas déjà invité
|
||||
if (!content.includes(send.author_id) ||
|
||||
this.data["invited"].includes(send.author_id))
|
||||
this.data.invited.includes(send.author_id))
|
||||
return;
|
||||
|
||||
this.data["invited"] = content;
|
||||
this.data.invited = content;
|
||||
let sender = await this.client.profiles.getProfileId(send.author_id);
|
||||
|
||||
create_popup("Invitation received by " + sender.username);
|
||||
@ -152,24 +152,24 @@ class Notice {
|
||||
let content = send.online;
|
||||
if (content !== undefined) {
|
||||
|
||||
if (this.data["online"].length > 0) {
|
||||
if (this.data.online.length > 0) {
|
||||
// get all disconnect user
|
||||
//let disconnects = this.data["online"].filter(id => !Object.keys(content).includes(id));
|
||||
|
||||
let disconnects = [];
|
||||
|
||||
for (const [key, value] of Object.entries(this.data["online"])) {
|
||||
for (const [key, value] of Object.entries(this.data.online)) {
|
||||
if (content[key] == "red" && value == "green")
|
||||
disconnects.push(key);
|
||||
}
|
||||
|
||||
// delete invite
|
||||
this.data["invited"] = this.data["invited"].filter(id => !disconnects.includes(id));
|
||||
this.data.invited = this.data.invited.filter(id => !disconnects.includes(id));
|
||||
|
||||
//console.log(this.data["invited"]);
|
||||
}
|
||||
|
||||
this.data["online"] = content;
|
||||
this.data.online = content;
|
||||
|
||||
if (this.rewrite_usernames !== undefined)
|
||||
this.rewrite_usernames();
|
||||
@ -202,12 +202,12 @@ class Notice {
|
||||
//this.data["asker"].includes(send.author_id))
|
||||
//return;
|
||||
|
||||
this.data["asked"] = send.asked;
|
||||
this.data["asker"] = send.asker;
|
||||
this.data.asked = send.asked;
|
||||
this.data.asker = send.asker;
|
||||
|
||||
if (send.author_id != my_id) {
|
||||
let sender = await this.client.profiles.getProfileId(send.author_id);
|
||||
if (this.data["asker"].includes(send.author_id))
|
||||
if (this.data.asker.includes(send.author_id))
|
||||
create_popup(sender.username + " ask you as friend");
|
||||
if (this.rewrite_profile !== undefined)
|
||||
await this.rewrite_profile();
|
||||
@ -248,8 +248,8 @@ class Notice {
|
||||
}
|
||||
|
||||
async receive_accept_friend(send) {
|
||||
this.data["asked"] = send.asked;
|
||||
this.data["asker"] = send.asker;
|
||||
this.data.asked = send.asked;
|
||||
this.data.asker = send.asker;
|
||||
let sender = await this.client.profiles.getProfileId(send.author_id);
|
||||
|
||||
if (send.author_id == this.client.me.id) {
|
||||
@ -279,8 +279,8 @@ class Notice {
|
||||
}
|
||||
|
||||
async receive_refuse_friend(send) {
|
||||
this.data["asked"] = send.asked;
|
||||
this.data["asker"] = send.asker;
|
||||
this.data.asked = send.asked;
|
||||
this.data.asker = send.asker;
|
||||
let sender = await this.client.profiles.getProfileId(send.author_id);
|
||||
|
||||
if (send.author_id == this.client.me.id) {
|
||||
@ -304,4 +304,4 @@ class Notice {
|
||||
}
|
||||
}
|
||||
|
||||
export {Notice}
|
||||
export {Notice};
|
||||
|
Reference in New Issue
Block a user