conversationsFlow

abstract fun conversationsFlow(limit: Int, olderThanConversation: Conversation? = null, conversationId: UUID? = null, forceRefresh: Boolean = false): Flow<Result<List<Conversation>>>

Retrieves conversations available to the local participant as a Flow.

This is the reactive equivalent of the suspend conversations function. The flow emits updated results as conversation data changes.

Return

A Flow emitting Result containing the list of conversations.

Parameters

limit

The maximum number of results to return.

olderThanConversation

The comparison conversation which serves as a base for returning older conversations. If null, the query starts from the newest known conversation.

conversationId

The conversation ID if querying for a particular Conversation.

forceRefresh

Forces the requested data to be refreshed over the network when set to true. Otherwise, the requested data is fetched from the local cache and only refreshed over the network if no results are found locally. Default value is false.

Samples

scope.launch {
    coreClient.conversationsFlow(limit = 20)
        .map { (it as? Result.Success)?.data.orEmpty() }
        .collect { conversations ->
            // Use the conversations list to update UI state
        }
}

abstract fun conversationsFlow(limit: Int, sortedByActivityDescending: Boolean = true, olderThanConversation: Conversation? = null): Flow<Result<List<Conversation>>>

Retrieves conversations from the local cache sorted by latest activity as a Flow.

This is the reactive equivalent of the suspend conversations function that operates on cached data. The flow emits updated results as locally cached conversation data changes.

Results are based on locally cached data and may not reflect the real-time state of conversations if the client has not yet retrieved the latest activity from the server. The activity data used for sorting must already exist in local device storage — populate it first by calling conversations with forceRefresh = true or conversationsFlow.

Return

A Flow emitting Result containing the list of conversations.

Parameters

limit

The maximum number of conversations to return.

sortedByActivityDescending

When true, returns conversations with the most recent activity first. Default value is true.

olderThanConversation

The comparison conversation which serves as a base for returning older conversations. If null, the query starts from the newest known conversation.