archiveChats method

Future<void> archiveChats(
  1. bool archive
)

Archives or unarchives the selectedChats.

Implementation

Future<void> archiveChats(bool archive) async {
  selecting.value = false;

  router.navigation.value = !selecting.value;
  router.navigator.value = null;

  try {
    await Future.wait(
      selectedChats.map(
        (chatId) => _chatService.archiveChat(chatId, archive),
      ),
    );
  } on ToggleChatArchivationException catch (e) {
    MessagePopup.error(e);
  } catch (e) {
    MessagePopup.error(e);
    rethrow;
  } finally {
    selectedChats.clear();
  }
}