patchPreferences abstract method

Future<ChatResult<RoomPreferences>> patchPreferences(
  1. String roomId, {
  2. bool? muted,
  3. DateTime? muteUntil,
  4. bool? pinned,
  5. bool? hidden,
})

Updates the current user's private room preferences in a single request and returns the merged server-side state.

All preferences are per-user: they only affect the calling user and are invisible to other members. Pass only the fields you want to change — omitted parameters are left untouched server-side.

  • mutedtrue to silence notifications, false to unmute. For a timed mute pass muteUntil instead (which implies muted: true).
  • muteUntil — mute only until that instant (WhatsApp-style 8h / 1 week timed mutes). Sent as an ISO-8601 string; the backend derives muted by comparing it with the current time. Mutually exclusive with an explicit muted value.
  • pinnedtrue to pin the room to the top of the list.
  • hiddentrue to hide (archive) the room from getUserRooms.

On success the roomDetail:<roomId>, rooms:all, and rooms:unread TTL keys are invalidated so the next read reflects the change.

This is the canonical preferences endpoint; mute, unmute, pin, unpin, hide, and unhide are thin wrappers that delegate here.

final res = await client.rooms.patchPreferences(
  roomId,
  pinned: true,
  hidden: false,
);
switch (res) {
  case ChatSuccess(:final data): print(data.pinned); // true
  case ChatFailureResult(:final failure): showError(failure);
}

Implementation

Future<ChatResult<RoomPreferences>> patchPreferences(
  String roomId, {
  bool? muted,
  DateTime? muteUntil,
  bool? pinned,
  bool? hidden,
});