Add chat message pagination

pull/4/head
trivernis 5 years ago
parent 29a1e7bfb3
commit b60b08b7b3

@ -341,7 +341,7 @@ type ChatRoom {
members(first: Int=10, offset: Int=0): [User!]
"return a specfic range of messages posted in the chat"
messages(first: Int = 10, offset: Int, containing: String): [ChatMessage]!
messages(first: Int = 10, offset: Int): [ChatMessage]!
"id of the chat"
id: ID!

@ -37,8 +37,10 @@ export class ChatRoom extends Model<ChatRoom> {
/**
* Returns the messages that have been sent in the chatroom
*/
public async messages(): Promise<ChatMessage[]> {
return await this.$get("rMessages") as ChatMessage[];
public async messages({first, offset}: {first: number, offset: number}): Promise<ChatMessage[]> {
const limit = first ?? 10;
offset = offset ?? 0;
return await this.$get("rMessages", {limit, offset}) as ChatMessage[];
}
/**

Loading…
Cancel
Save