Repository navigation
fix(blocklist): keep the cached name when a blocked user's profile fetch fails - #1588
Merged
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.refreshandBlocklistRemoteMediatorresolve each blocked user withgetProfileForUser(...).getOrNull(), so the profile is null whenever that call fails.BlockedUserDataSource.writeProfilethen wroteprofile?.displayName.orEmpty()throughupsertNameAndAvatar, which already kept the cached avatar on a null (viaCOALESCE) but always overwrote the name.upsertNameAndAvatarnow takes a nullable name andCOALESCEs 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"", becausedisplay_nameis NOT NULL.Tests, in
UserProfileDaoTest:"". Both fail without theCOALESCE.Found while checking how an empty name reaches the transcript for #1587.