mirror of
https://github.com/stoatchat/javascript-client-sdk.git
synced 2026-07-21 04:25:27 -04:00
Fetch group recipients upon first seeing a group.
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "revolt.js",
|
||||
"version": "4.0.0-alpha.15",
|
||||
"version": "4.0.0-alpha.16",
|
||||
"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.15';
|
||||
export const LIBRARY_VERSION = '4.0.0-alpha.16';
|
||||
|
||||
export const defaultConfig = {
|
||||
apiURL: 'https://api.revolt.chat',
|
||||
|
||||
@@ -26,6 +26,15 @@ export default class Channels extends Collection<Channel> {
|
||||
async fetchMutable(id: string) {
|
||||
if (this.map[id]) return this.get(id) as Channel;
|
||||
let res = await this.client.req<'GET', '/channels/:id'>('GET', `/channels/${id}` as any);
|
||||
|
||||
// Fetch user information if this is the first time we are seeing this object.
|
||||
// We shouldn't need to fetch for anything apart from groups.
|
||||
if (res.channel_type === 'Group') {
|
||||
for (let member of res.recipients) {
|
||||
await this.client.users.fetch(member);
|
||||
}
|
||||
}
|
||||
|
||||
this.set(res);
|
||||
return this.get(id) as Channel;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user