createLink method

Future<void> createLink()

Creates a ChatDirectLink from the link.

Implementation

Future<void> createLink() async {
  final String text = link.text.replaceFirst(_origin, '');

  if (myUser.value?.chatDirectLink?.slug.val == text) {
    return;
  }

  if (!link.status.value.isEmpty) {
    return;
  }

  try {
    await _myUserService.createChatDirectLink(ChatDirectLinkSlug(text));
  } on CreateChatDirectLinkException catch (e) {
    link.error.value = e.toMessage();
  } catch (e) {
    MessagePopup.error(e);
    rethrow;
  }
}