src/client/websocket/packets/WebSocketPacketManager.js

Unify ready and reconnecting properties into a single status property
and future-proof Message class
The state of the WebSocketManager is now represented by a single
status property, removing emittedReady
and reconnecting as representations of state.
Message class will now also cache users it isn't aware of that appear
in mentions and authors.
This commit is contained in:
hydrabolt
2016-04-20 17:45:20 +01:00
parent acc9c9bf12
commit b8283a8f29
6 changed files with 24 additions and 12 deletions

View File

@@ -33,7 +33,7 @@ class Guild {
guildUser.joined_at = guildUser.joined_at || 0;
let member = this.store.add('members', new GuildMember(this, guildUser));
if (this.client.ws.emittedReady && !noEvent) {
if (this.client.ws.status === Constants.Status.READY && !noEvent) {
this.client.emit(Constants.Events.GUILD_MEMBER_ADD, this, member);
}
@@ -44,14 +44,14 @@ class Guild {
let oldRoles = member.roles;
member._roles = data.roles;
if (this.client.ws.emittedReady) {
if (this.client.ws.status === Constants.Status.READY) {
this.client.emit(Constants.Events.GUILD_MEMBER_ROLES_UPDATE, this, oldRoles, member.roles);
}
}
_removeMember(guildMember) {
this.store.remove('members', guildMember);
if (this.client.ws.emittedReady) {
if (this.client.ws.status === Constants.Status.READY) {
this.client.emit(Constants.Events.GUILD_MEMBER_REMOVE, this, guildMember);
}
}