Optimise contact list requests in the RC widget

  • 1
  • Question
  • Updated 15 hours ago
When routing to /contacts list page in the RC widget, getContact event will trigger. This flow will be get seems a bit not optimized, that need to get all the contacts again and again.
So better solution only get updated contact list when routing to /contacts and update the existing contacts.
Can you trigger any other event for getting contacts, since getContacts will trigger at the start.
Or is any way to get back the contacts then I can merge the updated contacts.
Photo of sharmilan A

sharmilan A

  • 538 Points 500 badge 2x thumb

Posted 1 week ago

  • 1
Photo of Embbnux Ji

Embbnux Ji, Employee

  • 1,198 Points 1k badge 2x thumb
Hi, Sharmilan. Thanks so much for feedback. Yes, you are right. The widget should only request updated contacts when user go to contacts page. I have create a issue to follow this. It will be updated in about a week. Will keep you updated.  https://github.com/ringcentral/ringcentral-embeddable/issues/169
Photo of sharmilan A

sharmilan A

  • 538 Points 500 badge 2x thumb
Thank you Embbnux Ji, Can you make it as much as possible please?
Photo of Embbnux Ji

Embbnux Ji, Employee

  • 1,198 Points 1k badge 2x thumb
Hi, Sharmilan, I am tracking this bug. Can you provide some more detail messages, such as log message? I can't reproduce this in my computer. And which version of widget are you using? 
Photo of sharmilan A

sharmilan A

  • 538 Points 500 badge 2x thumb
Hi, I am using the master one, no any version. Can you add 10,000 contacts by using third-party request with the pagination like 100 contacts per request? Once all done, the visit /contacts page inside the widget should be get only updated contacts like 5 contacts.
The issue is after this scenario only showing 5 contacts which are collected from the last request only not merging with old contacts.
Photo of Embbnux Ji

Embbnux Ji, Employee

  • 1,198 Points 1k badge 2x thumb
Hi, Sharmilan, do you return new syncTimestamp when you response to updated contacts? And every contact should have unique id.
(Edited)
Photo of sharmilan A

sharmilan A

  • 538 Points 500 badge 2x thumb
Hi,
Yes, and I am using a unique contact id too. I am sending this response as like this,
{
    data: formatContactList(res),
    nextPage: (_links.next) ? request.body.page + 1 : null,
    syncTimestamp: (!_links.next) ? Date.now() : null,
}
 For large dataset I couldn't get that syncTimestamp back. Working well for small amount of contacts
Photo of Embbnux Ji

Embbnux Ji, Employee

  • 1,198 Points 1k badge 2x thumb
Hi, Sharmilan, please just set syncTimestamp  to `Date.now()`. 
{
    data: formatContactList(res),
    nextPage: (_links.next) ? request.body.page + 1 : null,
    syncTimestamp: Date.now()
}
Widget will use syncTimestamp from first page response in last request.
(Edited)