diff --git a/.dist/channel.js b/.dist/channel.js index 5b0d9b2..22b1527 100644 --- a/.dist/channel.js +++ b/.dist/channel.js @@ -102,24 +102,24 @@ class Channel { return true; }.bind(this), this.readbottom.bind(this)); } - constructor(JSON, owner) { - if (JSON === -1) { + constructor(json, owner) { + if (json === -1) { return; } this.editing; - this.type = JSON.type; + this.type = json.type; this.owner = owner; this.headers = this.owner.headers; - this.name = JSON.name; - this.snowflake = new SnowFlake(JSON.id, this); - this.parent_id = new SnowFlake(JSON.parent_id, undefined); + this.name = json.name; + this.snowflake = new SnowFlake(json.id, this); + this.parent_id = new SnowFlake(json.parent_id, undefined); this.parent = null; this.children = []; - this.guild_id = JSON.guild_id; + this.guild_id = json.guild_id; this.messageids = new Map(); this.permission_overwrites = new Map(); this.permission_overwritesar = []; - for (const thing of JSON.permission_overwrites) { + for (const thing of json.permission_overwrites) { if (thing.id === "1182819038095799904" || thing.id === "1182820803700625444") { continue; } @@ -127,11 +127,11 @@ class Channel { this.permission_overwrites.set(thing.id, new Permissions(thing.allow, thing.deny)); this.permission_overwritesar.push([thing.id, this.permission_overwrites.get(thing.id)]); } - this.topic = JSON.topic; - this.nsfw = JSON.nsfw; - this.position = JSON.position; + this.topic = json.topic; + this.nsfw = json.nsfw; + this.position = json.position; this.lastreadmessageid = null; - this.lastmessageid = SnowFlake.getSnowFlakeFromID(JSON.last_message_id, Message); + this.lastmessageid = SnowFlake.getSnowFlakeFromID(json.last_message_id, Message); this.setUpInfiniteScroller(); } isAdmin() { @@ -563,10 +563,10 @@ class Channel { } } } - delChannel(JSON) { + delChannel(json) { const build = []; for (const thing of this.children) { - if (thing.snowflake !== JSON.id) { + if (thing.snowflake !== json.id) { build.push(thing); } } @@ -644,16 +644,16 @@ class Channel { } return id; } - updateChannel(JSON) { - this.type = JSON.type; - this.name = JSON.name; - this.parent_id = new SnowFlake(JSON.parent_id, undefined); + updateChannel(json) { + this.type = json.type; + this.name = json.name; + this.parent_id = new SnowFlake(json.parent_id, undefined); this.parent = null; this.children = []; - this.guild_id = JSON.guild_id; + this.guild_id = json.guild_id; this.messageids = new Map(); this.permission_overwrites = new Map(); - for (const thing of JSON.permission_overwrites) { + for (const thing of json.permission_overwrites) { if (thing.id === "1182819038095799904" || thing.id === "1182820803700625444") { continue; } @@ -661,8 +661,8 @@ class Channel { this.permission_overwrites.set(thing.id, new Permissions(thing.allow, thing.deny)); this.permission_overwritesar.push([thing.id, this.permission_overwrites.get(thing.id)]); } - this.topic = JSON.topic; - this.nsfw = JSON.nsfw; + this.topic = json.topic; + this.nsfw = json.nsfw; } typingstart() { if (this.typing > new Date().getTime()) { diff --git a/.dist/direct.js b/.dist/direct.js index d100f0e..5efe8c8 100644 --- a/.dist/direct.js +++ b/.dist/direct.js @@ -4,10 +4,10 @@ import { Message } from "./message.js"; import { User } from "./user.js"; import { SnowFlake } from "./snowflake.js"; class Direct extends Guild { - constructor(JSON, owner) { + constructor(json, owner) { super(-1, owner, null); this.message_notifications = 0; - console.log(JSON); + console.log(json); this.owner = owner; if (!this.localuser) { console.error("Owner was not included, please fix"); @@ -21,16 +21,16 @@ class Direct extends Guild { this.roleids = new Map(); this.prevchannel = undefined; this.properties.name = "Direct Messages"; - for (const thing of JSON) { + for (const thing of json) { const temp = new Group(thing, this); this.channels.push(temp); this.channelids[temp.id] = temp; } this.headchannels = this.channels; } - createChannelpac(JSON) { - const thischannel = new Group(JSON, this); - this.channelids[JSON.id] = thischannel; + createChannelpac(json) { + const thischannel = new Group(json, this); + this.channelids[json.id] = thischannel; this.channels.push(thischannel); this.calculateReorder(); this.printServers(); @@ -61,26 +61,26 @@ class Direct extends Guild { } class Group extends Channel { user; - constructor(JSON, owner) { + constructor(json, owner) { super(-1, owner); this.owner = owner; this.headers = this.guild.headers; - this.name = JSON.recipients[0]?.username; - if (JSON.recipients[0]) { - this.user = new User(JSON.recipients[0], this.localuser); + this.name = json.recipients[0]?.username; + if (json.recipients[0]) { + this.user = new User(json.recipients[0], this.localuser); } else { this.user = this.localuser.user; } this.name ??= this.localuser.user.username; - this.snowflake = new SnowFlake(JSON.id, this); + this.snowflake = new SnowFlake(json.id, this); this.parent_id = null; this.parent = null; this.children = []; this.guild_id = "@me"; this.messageids = new Map(); this.permission_overwrites = new Map(); - this.lastmessageid = SnowFlake.getSnowFlakeFromID(JSON.last_message_id, Message); + this.lastmessageid = SnowFlake.getSnowFlakeFromID(json.last_message_id, Message); this.lastmessageid ??= new SnowFlake("0", undefined); this.mentions = 0; this.setUpInfiniteScroller(); diff --git a/.dist/guild.js b/.dist/guild.js index f8fffaf..6f58e53 100644 --- a/.dist/guild.js +++ b/.dist/guild.js @@ -397,8 +397,8 @@ class Guild { loadGuild() { this.localuser.loadGuild(this.id); } - updateChannel(JSON) { - SnowFlake.getSnowFlakeFromID(JSON.id, Channel).getObject().updateChannel(JSON); + updateChannel(json) { + SnowFlake.getSnowFlakeFromID(json.id, Channel).getObject().updateChannel(json); this.headchannels = []; for (const thing of this.channels) { thing.children = []; @@ -410,9 +410,9 @@ class Guild { } this.printServers(); } - createChannelpac(JSON) { - const thischannel = new Channel(JSON, this); - this.channelids[JSON.id] = thischannel; + createChannelpac(json) { + const thischannel = new Channel(json, this); + this.channelids[json.id] = thischannel; this.channels.push(thischannel); thischannel.resolveparent(this); if (!thischannel.parent) { @@ -461,9 +461,9 @@ class Guild { ]); channelselect.show(); } - delChannel(JSON) { - const channel = this.channelids[JSON.id]; - delete this.channelids[JSON.id]; + delChannel(json) { + const channel = this.channelids[json.id]; + delete this.channelids[json.id]; this.channels.splice(this.channels.indexOf(channel), 1); const indexy = this.headchannels.indexOf(channel); if (indexy !== -1) { @@ -478,7 +478,7 @@ class Guild { }else{ console.log("fail"); if(thing.parent){ - thing.parent.delChannel(JSON); + thing.parent.delChannel(json); } } } diff --git a/.dist/localuser.js b/.dist/localuser.js index 8238ef0..d66cc47 100644 --- a/.dist/localuser.js +++ b/.dist/localuser.js @@ -8,7 +8,7 @@ import { SnowFlake } from "./snowflake.js"; import { Message } from "./message.js"; const wsCodesRetry = new Set([4000, 4003, 4005, 4007, 4008, 4009]); class Localuser { - packets; + lastSequence = null; token; userinfo; serverurls; @@ -32,7 +32,6 @@ class Localuser { connectionSucceed = 0; errorBackoff = 0; constructor(userinfo) { - this.packets = 1; this.token = userinfo.token; this.userinfo = userinfo; this.serverurls = this.userinfo.serverurls; @@ -132,6 +131,8 @@ class Localuser { this.ws.addEventListener('message', (event) => { const temp = JSON.parse(event.data); console.log(temp); + if (temp.s) + this.lastSequence = temp.s; if (temp.op == 0) { switch (temp.t) { case "MESSAGE_CREATE": @@ -203,12 +204,8 @@ class Localuser { this.wsinterval = setInterval(_ => { if (this.connectionSucceed === 0) this.connectionSucceed = Date.now(); - this.ws.send(JSON.stringify({ op: 1, d: this.packets })); + this.ws.send(JSON.stringify({ op: 1, d: this.lastSequence })); }, temp.d.heartbeat_interval); - this.packets = 1; - } - else if (temp.op != 11) { - this.packets++; } }); this.ws.addEventListener("close", event => { @@ -249,24 +246,24 @@ class Localuser { } return undefined; } - updateChannel(JSON) { - SnowFlake.getSnowFlakeFromID(JSON.guild_id, Guild).getObject().updateChannel(JSON); - if (JSON.guild_id === this.lookingguild.id) { - this.loadGuild(JSON.guild_id); + updateChannel(json) { + SnowFlake.getSnowFlakeFromID(json.guild_id, Guild).getObject().updateChannel(json); + if (json.guild_id === this.lookingguild.id) { + this.loadGuild(json.guild_id); } } - createChannel(JSON) { - JSON.guild_id ??= "@me"; - SnowFlake.getSnowFlakeFromID(JSON.guild_id, Guild).getObject().createChannelpac(JSON); - if (JSON.guild_id === this.lookingguild.id) { - this.loadGuild(JSON.guild_id); + createChannel(json) { + json.guild_id ??= "@me"; + SnowFlake.getSnowFlakeFromID(json.guild_id, Guild).getObject().createChannelpac(json); + if (json.guild_id === this.lookingguild.id) { + this.loadGuild(json.guild_id); } } - delChannel(JSON) { - JSON.guild_id ??= "@me"; - this.guildids.get(JSON.guild_id).delChannel(JSON); - if (JSON.guild_id === this.lookingguild.snowflake) { - this.loadGuild(JSON.guild_id); + delChannel(json) { + json.guild_id ??= "@me"; + this.guildids.get(json.guild_id).delChannel(json); + if (json.guild_id === this.lookingguild.snowflake) { + this.loadGuild(json.guild_id); } } init() { diff --git a/.dist/role.js b/.dist/role.js index 083c9db..26047de 100644 --- a/.dist/role.js +++ b/.dist/role.js @@ -16,17 +16,17 @@ class Role { get id() { return this.snowflake.id; } - constructor(JSON, owner) { + constructor(json, owner) { this.headers = owner.headers; this.info = owner.info; - for (const thing of Object.keys(JSON)) { + for (const thing of Object.keys(json)) { if (thing === "id") { - this.snowflake = new SnowFlake(JSON.id, this); + this.snowflake = new SnowFlake(json.id, this); continue; } - this[thing] = JSON[thing]; + this[thing] = json[thing]; } - this.permissions = new Permissions(JSON.permissions); + this.permissions = new Permissions(json.permissions); this.owner = owner; } get guild() { diff --git a/webpage/style.css b/webpage/style.css index d98dbe9..eacb1ad 100644 --- a/webpage/style.css +++ b/webpage/style.css @@ -757,7 +757,7 @@ textarea:focus-visible { } .servernamediv { - width: 99%; + width: 100%; /* max-width: 100%; */ }