getDeviceForMember method

Future<IGroupCallRoomMemberDevice?> getDeviceForMember(
  1. String userId
)

Implementation

Future<IGroupCallRoomMemberDevice?> getDeviceForMember(String userId) async {
  final memberStateEvent = getMemberStateEvent(userId);
  if (memberStateEvent == null) {
    return null;
  }

  final memberState = IGroupCallRoomMemberState.fromJson(memberStateEvent);

  final memberGroupCallState =
      memberState.calls.where(((call) => call.call_id == groupCallId));

  if (memberGroupCallState.isEmpty) {
    return null;
  }

  final memberDevices = memberGroupCallState.first.devices;

  if (memberDevices.isEmpty) {
    return null;
  }

  /// NOTE: For now we only support one device so we use the device id in
  /// the first source.
  return memberDevices[0];
}