'Failed to fetch' error with display-photo component

I have popups with display-photo and display-file components, and when there is a no internet connection, it shows the ‘Failed to fetch’ error (since it tries to get an image/file on demand and it can’t finish the request).

Do you have any workaround for this error?
Could I somehow change the behavior of that error (and show different alert, for example)?

@khilda

We are busy working on a deterministic way to sync attachments down to the devices using special sync rules, but at the moment attachments are not synched automatically, need to be fetched on demand and therefore not available offline (at least not deterministically, they are available for a limited time if they have already been fetched on demand).

For now then you will need to basically do a “online/offline” check before trying to show the attachments. Please take a look at this post for suggestions on how to implement an online/offline check

@tielman I understand that photos and files request on demand.
But the option to test the connection before view opening does not cover all situations. For example, we have views with a lot of pictures, and even if you check the Internet before opening the view, it may end in the process.

My question was, rather, is it possible to somehow remove/hide the popup with error itself and just leave ‘Failed to retrieve file. Retry’ in place of display-photo/display-file.

@khilda This is what I expect to see when I try to display an attachment that isn’t cached on the device

Where are you seeing the error message? Is your display-photo component nested inside of something else like a dialog or object-repeat?

As discussed offline, the error message you were seeing was as a result of an OnlineDB query that was trying to refresh whilst offline, and was unrelated to the display-image / display-photo component