markUnread method

JsonMap markUnread(
  1. String principalId,
  2. String threadId,
  3. int lastRead,
  4. int expectedVersion, {
  5. String? deviceId,
})

markThreadUnread: moves the read position of principalId in threadId back to lastRead when expectedVersion is the version of its read state (04 14), and appends read_state.updated. Throws 412 version_conflict with the current state.

Implementation

JsonMap markUnread(
  String principalId,
  String threadId,
  int lastRead,
  int expectedVersion, {
  String? deviceId,
}) {
  visibleThread(principalId, threadId);
  final current = readStates['$principalId|$threadId'];
  final version = (current?['version'] as int?) ?? 0;
  if (version != expectedVersion) {
    throw FakeProblem(412, 'version_conflict', current: current);
  }
  return putReadState(principalId, threadId, lastRead, deviceId: deviceId);
}