1
0
mirror of https://gitlab.com/comunic/comunicapiv2 synced 2025-07-16 06:38:04 +00:00

Can refresh conversation messages

This commit is contained in:
2019-11-30 16:35:32 +01:00
parent c9f25a46ae
commit 2d29db4900
3 changed files with 78 additions and 6 deletions

@ -255,6 +255,24 @@ export class ConversationsHelper {
},
limit: numberOfMessages,
order: "id DESC"
})).map(m => this.DBToConversationMessage(convID, m)).reverse();
}
/**
* Get the new messages of a conversation
*
* @param convID Target conversation ID
* @param lastMessageID The ID of the last known message
*/
public static async GetNewMessages(convID: number, lastMessageID: number): Promise<Array<ConversationMessage>> {
return (await DatabaseHelper.Query({
table: MESSAGES_TABLE,
where: {
conv_id: convID
},
customWhere: "ID > ?",
customWhereArgs: [lastMessageID.toString()],
order: "id"
})).map(m => this.DBToConversationMessage(convID, m));
}