Remember flows (#4533)
* Add Konsist test to ensure that the result of a function returning a flow is remembered. * Remember flows before they are collected by state. * Fix compilation issue * Make isOnline a val. * Make selectedUsers() a val. * Make flow() a val. * Make getUserConsent(), didAskUserConsent() and getAnalyticsId() some val. * Remove Timeline.paginationStatus() and replace by direct access to the underlined flow. * Simplify test * userConsentFlow must be initialized before because it's used in observeUserConsent * Fix test compilation
This commit is contained in:
parent
e557ee2c77
commit
a230b83e99
52 changed files with 221 additions and 172 deletions
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
package io.element.android.libraries.matrix.api.sync
|
||||
|
||||
import io.element.android.libraries.core.coroutine.mapState
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
|
||||
interface SyncService {
|
||||
|
|
@ -25,6 +24,6 @@ interface SyncService {
|
|||
* Flow of [SyncState]. Will be updated as soon as the current [SyncState] changes.
|
||||
*/
|
||||
val syncState: StateFlow<SyncState>
|
||||
}
|
||||
|
||||
fun SyncService.isOnline(): StateFlow<Boolean> = syncState.mapState { it != SyncState.Offline }
|
||||
val isOnline: StateFlow<Boolean>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,10 @@ interface Timeline : AutoCloseable {
|
|||
val membershipChangeEventReceived: Flow<Unit>
|
||||
suspend fun sendReadReceipt(eventId: EventId, receiptType: ReceiptType): Result<Unit>
|
||||
suspend fun paginate(direction: PaginationDirection): Result<Boolean>
|
||||
fun paginationStatus(direction: PaginationDirection): StateFlow<PaginationStatus>
|
||||
|
||||
val backwardPaginationStatus: StateFlow<PaginationStatus>
|
||||
val forwardPaginationStatus: StateFlow<PaginationStatus>
|
||||
|
||||
val timelineItems: Flow<List<MatrixTimelineItem>>
|
||||
|
||||
suspend fun sendMessage(
|
||||
|
|
@ -105,7 +108,7 @@ interface Timeline : AutoCloseable {
|
|||
caption: String?,
|
||||
formattedCaption: String?,
|
||||
progressCallback: ProgressCallback?,
|
||||
): Result<MediaUploadHandler>
|
||||
): Result<MediaUploadHandler>
|
||||
|
||||
suspend fun sendFile(
|
||||
file: File,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue