Use this to fetch all the tickets in descending order
async getAllConversations() {
let loop = true;
let page = 1;
let result: any;
let conversations: any[] = [];
while (loop) {
result = await this.getConversationsPage(page);
conversations = conversations.concat(result);
page ++;
if (result.length != 30) {
loop = false;
}
}
conversations = conversations.filter(c => !c.private);
conversations.sort((a, b) => (new Date(a.updated_at) > new Date(b.updated_at)) ? -1 : 1);
return conversations;
}
getConversationsPage(page: number) {
return this._freshdeskService.getTicketConversations(this.ticketId, page).toPromise();
}