createChatDirectLink method

  1. @override
Future<void> createChatDirectLink(
  1. ChatDirectLinkSlug slug
)
override

Creates a new ChatDirectLink with the specified ChatDirectLinkSlug and deletes the current active ChatDirectLink of the authenticated MyUser (if any).

Implementation

@override
Future<void> createChatDirectLink(ChatDirectLinkSlug slug) async {
  Log.debug('createChatDirectLink($slug)', '$runtimeType');

  // Don't do optimism, as [slug] might be occupied, thus shouldn't set the
  // link right away.
  await _graphQlProvider.createUserDirectLink(slug);

  myUser.update(
    (u) => u?.chatDirectLink = ChatDirectLink(
      slug: slug,
      createdAt: PreciseDateTime.now(),
    ),
  );
}