mirror of
https://github.com/stoatchat/javascript-client-sdk.git
synced 2026-07-20 20:16:06 -04:00
feat: add lastMessage and displayName to Channel
This commit is contained in:
@@ -32,6 +32,10 @@ export class Channel {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
toString() {
|
||||
return `<#${this.id}>`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time when this server was created
|
||||
*/
|
||||
@@ -71,6 +75,17 @@ export class Channel {
|
||||
return this.#collection.getUnderlyingObject(this.id).name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display name
|
||||
*/
|
||||
get displayName() {
|
||||
return this.type === "SavedMessages"
|
||||
? this.user?.username
|
||||
: this.type === "DirectMessage"
|
||||
? this.recipient?.username
|
||||
: this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Channel description
|
||||
*/
|
||||
@@ -218,6 +233,13 @@ export class Channel {
|
||||
return this.#collection.getUnderlyingObject(this.id).lastMessageId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Last message sent in this channel
|
||||
*/
|
||||
get lastMessage() {
|
||||
return this.#collection.client.messages.get(this.lastMessageId!);
|
||||
}
|
||||
|
||||
/**
|
||||
* Time when the last message was sent
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user