From c0c0be44eb9da90659bb9e1fa79a150dd4eb4691 Mon Sep 17 00:00:00 2001 From: Paul Date: Sat, 27 Feb 2021 08:10:20 +0000 Subject: [PATCH] Fix recipients array being filled twice. --- package.json | 2 +- src/index.ts | 2 +- src/maps/Channels.ts | 2 +- src/websocket/client.ts | 5 +++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 1cd9960c..fc148ae2 100644 --- a/package.json +++ b/package.json @@ -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 ", diff --git a/src/index.ts b/src/index.ts index ec7dfa52..10ce18b6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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', diff --git a/src/maps/Channels.ts b/src/maps/Channels.ts index 0a0a4aa6..65a18936 100644 --- a/src/maps/Channels.ts +++ b/src/maps/Channels.ts @@ -41,7 +41,7 @@ export default class Channels extends Collection { 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 ]; } diff --git a/src/websocket/client.ts b/src/websocket/client.ts index c90ee0b8..35ed137f 100644 --- a/src/websocket/client.ts +++ b/src/websocket/client.ts @@ -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; }