No announcement yet.
  • Filter
  • Time
Clear All
new posts

    11.1 - problem with ListGrid getting dsResponse with status == 1 (offline) after calling refreshData


    I am playing with service worker to make application run offline.
    SmartClient version is 11.1 - 2018-12-25.

    I am detecting failed calls to RestDataSource endpoint in a service worker and, if the call failed because the client got offline, I am returning: {response: { status: 1 }}.
    Without that I am getting dsResponse with status == -90 (transport error) instead of 1 (offline).

    The problem is with the following scenario:
    1. I am online
    2. I fetch data to databound ListGrid from RestDataSource.
    3. I go offline (by disconnecting Wifi)
    4. I call ListGrid.refreshData
    5. I return {response: { status: 1 }} from service worker
    6. ListGrid's contents are replaced with ListGrid.emptyMessage

    Expected result for point 6 is to see ListGrid.offlineMessage.
    It works as expected if I call fetchData in point 4.

    I have just checked that if call refreshData on ListGrid that is already showing offlineMessage it is replaced by emptyMessage while offline.

    Also please take a look should I be getting dsResponse with status == 1 (offline) directly from SmartClient instead of status == -90 (transport error) when there is problem with connection without using service worker.

    Best regards,

    For a call to refreshData() that fails due to being offline, what you probably want to do is leave the data in place and show the user an indication that it may be stale, possibly as a pop-up. You can already do this. Removing the data instead and replacing it with the offline message seems worse.


      That's right and it should be made that way, but it is SmartClient that is removing data (or message that no data is available because of offline) and instead showing that there is no data (like "no data found").


        We've applied a fix back to SC 11.1p effective with the nightly builds dated 2018-12-30 and beyond so that we don't attempt to refresh data from the DSResponse if it has non-zero status. If the status is negative, the standard RPCManager error handling will also be invoked. The callback you supply to refreshData() can also take custom action according to the DSResponse.status.