Skip to content

fix(blocklist): keep the cached name when a blocked user's profile fetch fails - #1588

Merged
bmc08gt merged 1 commit into
code/cashfrom
fix/blocklist-keep-cached-name
Sep 28, 2026
Merged

bmc08gt merged 1 commit into
code/cashfrom
fix/blocklist-keep-cached-name

Conversation

@bmc08gt

@bmc08gt bmc08gt commented Sep 28, 2026

Copy link
Copy Markdown
Collaborator

A failed profile fetch during blocklist sync blanked the blocked user's cached name in user_profiles. That table is where the chat transcript, the Chats list, the activity feed and the blocked-users list read names from, so the blank showed on each of them until something else rewrote the row.

BlocklistCoordinator.refresh and BlocklistRemoteMediator resolve each blocked user with getProfileForUser(...).getOrNull(), so the profile is null whenever that call fails. BlockedUserDataSource.writeProfile then wrote profile?.displayName.orEmpty() through upsertNameAndAvatar, which already kept the cached avatar on a null (via COALESCE) but always overwrote the name.

upsertNameAndAvatar now takes a nullable name and COALESCEs it the same way. Null means there was no profile to write; an empty string from a successful fetch is a user with no display name and still replaces the cached one. With nothing cached, a null stores "", because display_name is NOT NULL.

Tests, in UserProfileDaoTest:

  • A null name keeps the cached name, and a null name with no row stores "". Both fail without the COALESCE.
  • An empty name replaces the cached name.

Found while checking how an empty name reaches the transcript for #1587.

…tch fails

BlocklistCoordinator.refresh and BlocklistRemoteMediator store each blocked
user's profile as getProfileForUser(...).getOrNull(), and writeProfile wrote
`profile?.displayName.orEmpty()`. A failed fetch therefore replaced a cached
display_name with "" in user_profiles, which every screen reads names from.

upsertNameAndAvatar now takes a nullable name and COALESCEs it with the cached
one, as it already did for the avatar. With nothing cached it stores "", since
the column is NOT NULL. An empty name from a successful fetch still replaces
the cached one.
@bmc08gt bmc08gt self-assigned this Sep 28, 2026
@github-actions github-actions Bot added the type: fix Bug fix label Sep 28, 2026
@bmc08gt
bmc08gt merged commit 69a2d6f into code/cash Sep 28, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: fix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant