change (media preview config) : final refactoring and tests
This commit is contained in:
parent
4b4cfa341e
commit
ca46166c67
27 changed files with 676 additions and 165 deletions
|
|
@ -8,7 +8,6 @@
|
|||
package io.element.android.libraries.matrix.api
|
||||
|
||||
import io.element.android.libraries.core.data.tryOrNull
|
||||
import io.element.android.libraries.core.extensions.runCatchingExceptions
|
||||
import io.element.android.libraries.matrix.api.core.DeviceId
|
||||
import io.element.android.libraries.matrix.api.core.MatrixPatterns
|
||||
import io.element.android.libraries.matrix.api.core.ProgressCallback
|
||||
|
|
@ -20,9 +19,7 @@ import io.element.android.libraries.matrix.api.core.UserId
|
|||
import io.element.android.libraries.matrix.api.createroom.CreateRoomParameters
|
||||
import io.element.android.libraries.matrix.api.encryption.EncryptionService
|
||||
import io.element.android.libraries.matrix.api.media.MatrixMediaLoader
|
||||
import io.element.android.libraries.matrix.api.media.MediaPreviewConfig
|
||||
import io.element.android.libraries.matrix.api.media.MediaPreviewService
|
||||
import io.element.android.libraries.matrix.api.media.MediaPreviewValue
|
||||
import io.element.android.libraries.matrix.api.notification.NotificationService
|
||||
import io.element.android.libraries.matrix.api.notificationsettings.NotificationSettingsService
|
||||
import io.element.android.libraries.matrix.api.oidc.AccountManagementAction
|
||||
|
|
@ -44,7 +41,6 @@ import kotlinx.collections.immutable.ImmutableList
|
|||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.util.Optional
|
||||
|
||||
interface MatrixClient {
|
||||
|
|
@ -175,7 +171,6 @@ interface MatrixClient {
|
|||
* Return true if Livekit Rtc is supported, i.e. if Element Call is available.
|
||||
*/
|
||||
suspend fun isLivekitRtcSupported(): Boolean
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -13,4 +13,14 @@ package io.element.android.libraries.matrix.api.media
|
|||
data class MediaPreviewConfig(
|
||||
val mediaPreviewValue: MediaPreviewValue,
|
||||
val hideInviteAvatar: Boolean,
|
||||
)
|
||||
) {
|
||||
companion object {
|
||||
/**
|
||||
* The default config if unknown (no local nor server config).
|
||||
*/
|
||||
val DEFAULT = MediaPreviewConfig(
|
||||
mediaPreviewValue = MediaPreviewValue.On,
|
||||
hideInviteAvatar = false
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
package io.element.android.libraries.matrix.api.media
|
||||
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
|
||||
interface MediaPreviewService {
|
||||
/**
|
||||
|
|
@ -19,24 +19,17 @@ interface MediaPreviewService {
|
|||
* Will emit the media preview config known by the client.
|
||||
* This will emit a new value when received from sync.
|
||||
*/
|
||||
fun getMediaPreviewConfigFlow(): Flow<MediaPreviewConfig?>
|
||||
|
||||
/**
|
||||
* Get the media preview display policy from the cache. This value is updated through sync.
|
||||
*/
|
||||
suspend fun getMediaPreviewValue(): MediaPreviewValue?
|
||||
|
||||
/**
|
||||
* Get the invite avatars display policy from the cache. This value is updated through sync.
|
||||
*/
|
||||
suspend fun getHideInviteAvatars(): Boolean
|
||||
val mediaPreviewConfigFlow: StateFlow<MediaPreviewConfig>
|
||||
|
||||
/**
|
||||
* Set the media preview display policy. This will update the value on the server and update the local value when successful.
|
||||
*/
|
||||
suspend fun setMediaPreviewValue(mediaPreviewValue: MediaPreviewValue): Result<Unit>
|
||||
|
||||
/**
|
||||
* Set the invite avatars display policy. This will update the value on the server and update the local value when successful.
|
||||
*/
|
||||
suspend fun setHideInviteAvatars(hide: Boolean): Result<Unit>
|
||||
}
|
||||
|
||||
fun MediaPreviewService.getMediaPreviewValue() = mediaPreviewConfigFlow.value.mediaPreviewValue
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue