update method
Future<ChatResult<ChatUser> >
update(
- String userId, {
- String? displayName,
- String? avatarUrl,
- bool clearAvatar = false,
- String? bio,
- String? email,
- Map<
String, dynamic> ? custom, - bool? active,
override
Updates profile fields for an existing user.
Call this from the profile editor when the user saves their
changes. The backend emits a user_updated WS event so the
authenticated principal's other devices (and rooms that render
their avatar/name) see the change in real time.
Pass clearAvatar: true to explicitly remove the current avatar
(sends an explicit JSON null so the backend wipes the field).
Passing avatarUrl: null without the flag is a no-op — the field
is omitted from the payload entirely.
Implementation
@override
Future<ChatResult<ChatUser>> update(
String userId, {
String? displayName,
String? avatarUrl,
bool clearAvatar = false,
String? bio,
String? email,
Map<String, dynamic>? custom,
bool? active,
}) async {
final existing = _client._users[userId];
if (existing == null) return const ChatFailureResult(NotFoundFailure());
final updated = ChatUser(
id: userId,
displayName: displayName ?? existing.displayName,
avatarUrl: clearAvatar ? null : (avatarUrl ?? existing.avatarUrl),
bio: bio ?? existing.bio,
email: email ?? existing.email,
custom: custom ?? existing.custom,
active: active ?? existing.active,
role: existing.role,
configuration: existing.configuration,
);
_client._users[userId] = updated;
return ChatSuccess(updated);
}