openAvatar function

Future<void> openAvatar(
  1. dynamic context,
  2. dynamic ref,
  3. String roomId
)

Implementation

Future<void> openAvatar(
  BuildContext context,
  WidgetRef ref,
  String roomId,
) async {
  final membership = await ref.read(roomMembershipProvider(roomId).future);
  final canUpdateAvatar = membership?.canString('CanUpdateAvatar') == true;
  final avatarInfo = ref.read(roomAvatarInfoProvider(roomId));

  if (avatarInfo.avatar != null && context.mounted) {
    //Open avatar in full screen if avatar data available
    context.pushNamed(
      Routes.fullScreenAvatar.name,
      queryParameters: {'roomId': roomId},
    );
  } else if (avatarInfo.avatar == null && canUpdateAvatar && context.mounted) {
    //Change avatar if avatar is null and have relevant permission
    uploadAvatar(ref, context, roomId);
  }
}