seedRoomMeta method
Test/demo helper: seed chat-list metadata (unread badge, pinned,
muted, write policy) that the real backend computes/stores but the mock
ChatRoom model doesn't carry. Null args leave the current value
untouched.
writePolicy closes the room to everyone but its owner exactly like the
backend's config.writePolicy does, and reaches both the listing
(UnreadRoom.writePolicy) and the detail (RoomConfig.writePolicy) —
the two sources the composer reads:
client.seedRoomMeta(roomId, writePolicy: RoomWritePolicy.ownerOnly);
userRole overrides the current user's role in RoomDetail.userRole,
which otherwise defaults to RoomRole.owner. Pair it with
writePolicy: RoomWritePolicy.ownerOnly and a non-owner role to seed a
room the current user can only read — the combination
ChatView/NomaChatView resolve into ReadOnlyReason.ownerOnly.
Implementation
void seedRoomMeta(
String roomId, {
int? unread,
bool? pinned,
bool? muted,
RoomWritePolicy? writePolicy,
RoomRole? userRole,
}) {
if (unread != null) _unread[roomId] = unread;
if (pinned != null) _pinned[roomId] = pinned;
if (muted != null) _muted[roomId] = muted;
if (writePolicy != null) _writePolicy[roomId] = writePolicy;
if (userRole != null) _userRole[roomId] = userRole;
}