openPublicProfile static method

void openPublicProfile(
  1. BuildContext context, {
  2. required String profileId,
  3. String currentProfileId = '',
  4. bool closeOverlay = false,
})

Opening an author's public profile is a catalogue read in Gigmeout. The destination revalidates it through publicProfiles; account actions still go through protect, including in that public profile page.

Implementation

static void openPublicProfile(
  BuildContext context, {
  required String profileId,
  String currentProfileId = '',
  bool closeOverlay = false,
}) {
  if (profileId.isEmpty ||
      profileId != profileId.trim() ||
      profileId.contains(RegExp(r'[/\\?#\s]')) ||
      profileId == '.' ||
      profileId == '..') {
    return;
  }

  final publicCatalog = PublicCatalogReadPolicy.enabled;
  final route = isAuthenticated && profileId == currentProfileId
      ? AppRouteConstants.profile
      : AppRouteConstants.matePath(profileId);
  void open() {
    if (closeOverlay) Sint.pop();
    Sint.toNamed(route, arguments: profileId);
  }

  if (publicCatalog) {
    open();
  } else {
    protect(context, open, redirectRoute: route, arguments: profileId);
  }
}