change (preferences) : bind timeline media preview with join rule
This commit is contained in:
parent
ca1c2ae4a4
commit
5725e328fe
2 changed files with 29 additions and 17 deletions
|
|
@ -7,6 +7,11 @@
|
|||
|
||||
package io.element.android.libraries.matrix.api.media
|
||||
|
||||
import io.element.android.libraries.matrix.api.media.MediaPreviewValue.Off
|
||||
import io.element.android.libraries.matrix.api.media.MediaPreviewValue.On
|
||||
import io.element.android.libraries.matrix.api.media.MediaPreviewValue.Private
|
||||
import io.element.android.libraries.matrix.api.room.join.JoinRule
|
||||
|
||||
/**
|
||||
* Represents the values for media preview settings.
|
||||
* - [On] means that media preview are enabled
|
||||
|
|
@ -18,3 +23,17 @@ enum class MediaPreviewValue {
|
|||
Off,
|
||||
Private
|
||||
}
|
||||
|
||||
fun MediaPreviewValue.isPreviewEnabled(joinRule: JoinRule?): Boolean {
|
||||
return when (this) {
|
||||
On -> true
|
||||
Off -> false
|
||||
Private -> when (joinRule) {
|
||||
is JoinRule.Knock,
|
||||
is JoinRule.Invite,
|
||||
is JoinRule.Restricted,
|
||||
is JoinRule.KnockRestricted -> true
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue