register method

Future<void> register()

Creates a new account and switches to it.

Implementation

Future<void> register() async {
  router.nowhere();

  try {
    await _authService.register(force: true);

    // TODO: This is a hack that should be removed, as whenever the account is
    //       changed, the [HomeView] and its dependencies must be rebuilt,
    //       which may take some unidentifiable amount of time as of now.
    await Future.delayed(500.milliseconds);

    router.tab = HomeTab.chats;
    router.home();
  } catch (e) {
    await Future.delayed(500.milliseconds);
    router.home();
    await Future.delayed(500.milliseconds);
    MessagePopup.error(e);
  }
}