isRoute method

bool isRoute(
  1. String route,
  2. UserId? me
)

Indicates whether the provided route represents this Chat.

Implementation

bool isRoute(String route, UserId? me) {
  final User? member = members.firstWhereOrNull((e) => e.user.id != me)?.user;

  final bool byId = route.startsWith('${Routes.chats}/$id');
  final bool byUser =
      isDialog &&
      member != null &&
      route.startsWith('${Routes.chats}/${ChatId.local(member.id)}');
  final bool byNum =
      isDialog &&
      member != null &&
      route.startsWith('${Routes.chats}/${ChatId(member.num.toString())}');
  final bool byMonolog =
      isMonolog &&
      me != null &&
      route.startsWith('${Routes.chats}/${ChatId.local(me)}');

  return byId || byUser || byMonolog || byNum;
}