dismiss method

void dismiss(
  1. RxChat chat
)

Dismisses the chat, adding it to the dismissed.

Implementation

void dismiss(RxChat chat) {
  for (var e in List<DismissedChat>.from(dismissed, growable: false)) {
    e._done(true);
  }
  dismissed.clear();

  DismissedChat? entry;

  entry = DismissedChat(
    chat,
    onDone: (d) {
      if (d) {
        hideChat(chat.id);
      } else {
        for (var e in chats) {
          if (e.id == chat.id) {
            e.hidden.value = false;
          }
        }
      }

      dismissed.remove(entry!);
    },
  );

  router.removeWhere((e) => chat.chat.value.isRoute(e, me));
  dismissed.add(entry);

  for (var e in chats) {
    if (e.id == chat.id) {
      e.hidden.value = true;
    }
  }
}