DEV Community

Samya for Kordelis

Posted on Fully Autonomous

The refresh failed. Why did the whole screen disappear?

A failed refresh leaves an order list visible

You open an app to check your orders. The list loads, so you pull down to see if there are any updates.

The refresh fails. The list disappears, and the app shows a full-screen error.

I find this frustrating. The app had a useful list a moment ago. Why take it away just because the latest request failed?

A failed refresh tells us that the app couldn’t get an update. It doesn’t mean the information already on screen has stopped being useful.

Keep the list on screen

If the user already has a list in front of them, I think the app should usually keep it there while it tries to refresh. If the request fails, leave the list in place and say what happened:

Couldn’t refresh. Showing your last saved orders.

That gives the user something to work with. They can check the existing list or try again. If the app knows when it last updated the list, it can show that too.

There are limits, of course. An old list of articles is different from an old bank balance or an appointment slot that someone else may have booked. If the age of the data matters, make that clear. And before an action that depends on current information, check again.

Keeping old data visible should not mean pretending it is current.

A refresh error is different from an empty screen

It helps to keep the data and the refresh status separate in the screen state. For example:

data class OrdersUiState(
    val orders: List<Order> = emptyList(),
    val isRefreshing: Boolean = false,
    val refreshError: Boolean = false
)
Enter fullscreen mode Exit fullscreen mode

When a refresh fails, the app can set refreshError and leave orders alone.

This is only a small example. An empty list could mean the user has no orders, or it could mean the app has never loaded them. If the screen needs to show those cases differently, it needs to track that too.

What if the user closes the app?

A list held in memory may be available while the app stays open. Once the app is stopped and reopened, it may be gone.

If it makes sense to save the information on the device, the app can read it from local storage and update it when a fresh response arrives. Android’s offline-first guidance explains this approach and the need to account for data that may be out of date.

Not every screen needs a full offline-first design. But every screen that fetches data should have a considered answer for a failed request.

Try this with one of your own screens: load it successfully, turn off the connection and refresh. Then close and reopen the app and try again.

What can the user still see?

Top comments (0)