import { ZocksSDK, Session, Participant, Track } from '@zocks-communications/client-sdk-js'

export const getSessionByRoomId = (roomId?: string | null): Session | undefined => {
  if (!roomId) {
    return
  }
  return ZocksSDK.getSessionById(roomId)
}

export const getTrackById = (participant?: Participant, trackId?: string | null): Track | null => {
  return (participant && trackId && participant.tracks.find((t) => t.id === trackId)) || null
}
