mirror of
https://github.com/stoatchat/javascript-client-sdk.git
synced 2026-07-20 20:16:06 -04:00
Fix a bug where we don't open saved messages channels.
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "revolt.js",
|
||||
"version": "4.0.0-alpha.14",
|
||||
"version": "4.0.0-alpha.15",
|
||||
"main": "dist/index.js",
|
||||
"repository": "https://gitlab.insrt.uk/revolt/revolt.js",
|
||||
"author": "Paul Makles <insrt.uk>",
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
export * from './Client';
|
||||
export { Channel, User, Message } from './api/objects';
|
||||
|
||||
export const LIBRARY_VERSION = '4.0.0-alpha.14';
|
||||
export const LIBRARY_VERSION = '4.0.0-alpha.15';
|
||||
|
||||
export const defaultConfig = {
|
||||
apiURL: 'https://api.revolt.chat',
|
||||
|
||||
+16
-4
@@ -20,10 +20,22 @@ export default class Users extends Collection<User> {
|
||||
|
||||
async openDM(id: string) {
|
||||
this.getThrow(id);
|
||||
let channel = this.client.channels
|
||||
.toArray()
|
||||
.find(channel => channel.channel_type === 'DirectMessage'
|
||||
&& channel.recipients.find(user => user === id));
|
||||
|
||||
let channel;
|
||||
if (id === this.client.user?._id) {
|
||||
channel = this.client
|
||||
.channels
|
||||
.toArray()
|
||||
.find(channel => channel.channel_type === 'SavedMessages');
|
||||
} else {
|
||||
channel = this.client
|
||||
.channels
|
||||
.toArray()
|
||||
.find(channel =>
|
||||
(channel.channel_type === 'DirectMessage'
|
||||
&& channel.recipients.find(user => user === id))
|
||||
);
|
||||
}
|
||||
|
||||
if (typeof channel === 'undefined') {
|
||||
channel = await this.client.req<'GET', '/users/:id/dm'>('GET', `/users/${id}/dm` as any);
|
||||
|
||||
Reference in New Issue
Block a user