removeFromDirectChat method

Future<void> removeFromDirectChat()

Removes this room from all direct chat tags.

Implementation

Future<void> removeFromDirectChat() async {
  final directChats = client.directChats.copy();
  for (final k in directChats.keys) {
    final directChat = directChats[k];
    if (directChat is List && directChat.contains(id)) {
      directChat.remove(id);
    }
  }

  directChats.removeWhere((_, v) => v is List && v.isEmpty);

  if (directChats == client.directChats) {
    return;
  }

  await client.setAccountData(
    client.userID!,
    'm.direct',
    directChats,
  );
  return;
}