updateProfileFields method
Applies whichever of username and displayName actually changed.
The two are separate endpoints because they are different things: the
username is unique and charset-constrained (and so can fail with
ErrorCode.usernameTaken or ErrorCode.usernameInvalid), while the
display name is free-form and cannot collide.
Implementation
Future<void> updateProfileFields({
String? username,
String? displayName,
}) async {
final current = await ref.read(currentUserProfileProvider.future);
final repository = ref.read(accountRepositoryProvider);
if (username != null && username != current.username) {
await _apply(await repository.updateUsername(username));
}
if (displayName != null && displayName != current.displayName) {
await _apply(await repository.updateDisplayName(displayName));
}
}