func update()

in AzureCommunicationUI/sdk/AzureCommunicationUICalling/Sources/Presentation/SwiftUI/Calling/Grid/ParticipantGridViewModel.swift [45:97]


    func update(callingState: CallingState,
                captionsState: CaptionsState,
                rttState: RttState,
                remoteParticipantsState: RemoteParticipantsState,
                visibilityState: VisibilityState,
                lifeCycleState: LifeCycleState) {

        guard lastUpdateTimeStamp != remoteParticipantsState.lastUpdateTimeStamp
                || lastDominantSpeakersUpdatedTimestamp != remoteParticipantsState.dominantSpeakersModifiedTimestamp
                || visibilityStatus != visibilityState.currentStatus
                || appStatus != lifeCycleState.currentStatus
        else {
            return
        }
        lastUpdateTimeStamp = remoteParticipantsState.lastUpdateTimeStamp
        lastDominantSpeakersUpdatedTimestamp = remoteParticipantsState.dominantSpeakersModifiedTimestamp
        visibilityStatus = visibilityState.currentStatus
        appStatus = lifeCycleState.currentStatus

        let remoteParticipants = remoteParticipantsState.participantInfoList
            .filter { participanInfoModel in
                participanInfoModel.status != .inLobby && participanInfoModel.status != .disconnected
            }
        let dominantSpeakers = remoteParticipantsState.dominantSpeakers
        let newDisplayedInfoModelArr = getDisplayedInfoViewModels(remoteParticipants, dominantSpeakers, visibilityState)
        let removedModels = getRemovedInfoModels(for: newDisplayedInfoModelArr)
        let addedModels = getAddedInfoModels(for: newDisplayedInfoModelArr)
        let orderedInfoModelArr = sortDisplayedInfoModels(newDisplayedInfoModelArr,
                                                          removedModels: removedModels,
                                                          addedModels: addedModels)
        updateCellViewModel(for: orderedInfoModelArr, lifeCycleState: lifeCycleState)

        displayedParticipantInfoModelArr = orderedInfoModelArr
        if callingState.status == .connected
            || callingState.status == .remoteHold
            || (callType == .oneToNOutgoing
        && ( callingState.status == .connecting || callingState.status == .ringing)) {
            // announce participants list changes only if the user is already connected to the call
            postParticipantsListUpdateAccessibilityAnnouncements(removedModels: removedModels,
                                                                 addedModels: addedModels)
        }

        updateVideoViewManager(displayedRemoteInfoModelArr: displayedParticipantInfoModelArr)

        if gridsCount != displayedParticipantInfoModelArr.count {
            gridsCount = displayedParticipantInfoModelArr.count
        }

        shouldUseVerticalStyleGrid =
        ScreenSizeClassKey.defaultValue == .iphonePortraitScreenSize ||
        captionsState.isCaptionsOn ||
        rttState.isRttOn
    }