leave method

Future<void> leave()

Call the SDN API to leave this room. If this room is set as a direct chat, this will be removed too.

Implementation

Future<void> leave() async {
  try {
    await client.leaveRoom(id);
  } on SDNException catch (exception) {
    if ([SDNError.M_NOT_FOUND, SDNError.M_UNKNOWN]
        .contains(exception.error)) {
      await _handleFakeSync(
        SyncUpdate(
          nextBatch: '',
          rooms: RoomsUpdate(
            leave: {
              id: LeftRoomUpdate(),
            },
          ),
        ),
      );
    }
    rethrow;
  }
  return;
}