Optimise contact list requests in the RC widget

  • 1
  • Question
  • Updated 16 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
You are welcome. Sure, I will work on it as soon as possible.
Photo of Embbnux Ji

Embbnux Ji, Employee

  • 1,198 Points 1k badge 2x thumb
Hi, Sharmilan

We have added this feature to master branch release. Please follow this document to update your codes. You need to add `syncTimestamp` in your contacts response. And in next request, widget will send you syncTimestamp back, and you just need to return updated contacts after sync timestamp. 

Looking forward to your feedback.
Thanks
Photo of sharmilan A

sharmilan A

  • 538 Points 500 badge 2x thumb
Thanks a lot, I ll check
Photo of sharmilan A

sharmilan A

  • 538 Points 500 badge 2x thumb
Hi Embbnux Ji,
This is working fine for the smaller amount of data. But if like 50 requests for CRM with little bit big response (Not huge like image data) the `syncTimestamp` not existing in the request.body
Why is that?
Before this fix I have added some workaround for this kind of issues.
Photo of Embbnux Ji

Embbnux Ji, Employee

  • 1,198 Points 1k badge 2x thumb
Hi, Sharmilan, I am not very clear about your `50 requests for CRM with little bit big response (Not huge like image data)`. Do you mean widget will send 50 requests in first full sync? In first full sync for large data, widget will send request with page number without `syncTimestamp`, you need to return paging data. And when user goto contacts page, widget will send request with `syncTimestamp`. You only need to return updated data since last sync timestamp.
Photo of sharmilan A

sharmilan A

  • 538 Points 500 badge 2x thumb
Hi,
Yes exactly, the issue is if I use for 50 requests for first full sync I couldn't get `syncTimestamp` in the update scenario like follows.
Full sync is completed when trying to update the contact list by visiting the /contacts page in a widget, I couldn't get the `syncTimestamp` in the request body, so it will do like a full sync again.

If the initial request count like 5 then works fine, can get that `syncTimestamp` as well
Photo of Embbnux Ji

Embbnux Ji, Employee

  • 1,198 Points 1k badge 2x thumb
Thanks, Sharmilan. Let me check it
Photo of sharmilan A

sharmilan A

  • 538 Points 500 badge 2x thumb
Thanks,
Even I have added a workaround for this like 11k contacts successfully synced for the first time, but not merge the update when I try to go /contacts page in the widget it removes earlier contacts and only shows the updated contacts and the RC account contacts.
(Edited)
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)