Fix recipients array being filled twice.

This commit is contained in:
Paul
2021-02-27 08:10:20 +00:00
parent 6380beb2e8
commit c0c0be44eb
4 changed files with 6 additions and 5 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "revolt.js",
"version": "4.0.0-alpha.5",
"version": "4.0.0-alpha.6",
"main": "dist/index.js",
"repository": "https://gitlab.insrt.uk/revolt/revolt.js",
"author": "Paul Makles <insrt.uk>",
+1 -1
View File
@@ -1,7 +1,7 @@
export * from './Client';
export { Channel, User, Message } from './api/objects';
export const LIBRARY_VERSION = '4.0.0-alpha.5';
export const LIBRARY_VERSION = '4.0.0-alpha.6';
export const defaultConfig = {
apiURL: 'https://api.revolt.chat',
+1 -1
View File
@@ -41,7 +41,7 @@ export default class Channels extends Collection<Channel> {
if (channel.channel_type !== 'Group') throw "Channel is not group channel.";
await this.client.req<'PUT', '/channels/:id/recipients/:id'>('PUT', `/channels/${id}/recipients/${user_id}` as any);
channel.recipients = [
...channel.recipients,
...channel.recipients.filter(user => user !== user_id),
user_id
];
}
+3 -2
View File
@@ -118,9 +118,10 @@ export class WebSocketClient {
case 'ChannelGroupJoin': {
let channel = await this.client.channels.fetchMutable(packet.id);
if (channel.channel_type !== 'Group') throw "Not a group channel.";
let user_id = packet.user;
channel.recipients = [
...channel.recipients,
packet.user
...channel.recipients.filter(user => user !== user_id),
user_id
];
break;
}