notes · thoughts ·
A refresh fixes it, but what should update?
The chat list, conversation, and unread count were connected. I want to decide which screens should show the same facts when data changes.
Working on chat made it impossible to treat the list, conversation, and unread message count separately. A single new message changes what appears in several places. If only one updates, the user sees conflicting states within the same app.
Refetching makes things look right again. That makes it tempting to add another fetch wherever something does not update. But in a feature with frequent events, I also need to look at how often that runs and how far its effects reach.
Where one event reaches
Looking back over my work, I repeatedly found tasks involving query keys, invalidation, and rollback. They looked like fixes for displays that updated late. Ultimately, they were decisions about which changes affect which data.
Receiving a new message and marking a conversation as read are different events. For each, I should be able to explain which parts need updating: the latest message in the list, the conversation contents, or the unread count. Adding update logic screen by screen makes it easy to handle the same event differently.
What I want to decide first is what must update immediately. Where should the result of the user’s latest action appear at once, and when is it acceptable to check it on another screen? Then I can choose whether to update the cache directly from the response or refetch.
If the UI changes first, the failure state needs a decision too. Without deciding what to roll back and whether to check the server again, the screen only feels natural when the operation succeeds.
I no longer see cache management only as an optimization to reduce requests. It also maintains states that make sense when a user sees the same activity in the list and detail views. Refetching may be necessary. I just want to know what consistency it restores and how far the update needs to go.