Add Konsist test to check that toPersistentList() is not used.
Same for `toPersistentSet()` and `toPersistentMap()`. Fix existing issues.
This commit is contained in:
parent
2fa1b9d448
commit
67c9daa0bf
85 changed files with 305 additions and 254 deletions
|
|
@ -27,7 +27,7 @@ import io.element.android.libraries.designsystem.components.avatar.avatarShape
|
|||
import io.element.android.libraries.designsystem.preview.ElementThemedPreview
|
||||
import io.element.android.libraries.designsystem.preview.PreviewGroup
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.toPersistentList
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
import java.util.Collections
|
||||
import kotlin.math.PI
|
||||
import kotlin.math.cos
|
||||
|
|
@ -134,7 +134,7 @@ internal fun AvatarClusterPreview() = ElementThemedPreview {
|
|||
) {
|
||||
for (ngOfAvatars in 1..5) {
|
||||
AvatarCluster(
|
||||
avatars = List(ngOfAvatars) { anAvatarData(it) }.toPersistentList(),
|
||||
avatars = List(ngOfAvatars) { anAvatarData(it) }.toImmutableList(),
|
||||
avatarType = avatarType,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
package io.element.android.libraries.designsystem.components.media
|
||||
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.toPersistentList
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
import kotlin.random.Random
|
||||
|
||||
/**
|
||||
|
|
@ -21,5 +21,5 @@ import kotlin.random.Random
|
|||
fun createFakeWaveform(length: Int = 1000): ImmutableList<Float> {
|
||||
val random = Random(seed = 2)
|
||||
return List(length) { random.nextFloat() }
|
||||
.toPersistentList()
|
||||
.toImmutableList()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ import io.element.android.libraries.designsystem.preview.ElementPreview
|
|||
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
import kotlinx.collections.immutable.toPersistentList
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
private const val DEFAULT_GRAPHICS_LAYER_ALPHA: Float = 0.99F
|
||||
|
|
@ -187,14 +187,14 @@ internal fun WaveformPlaybackViewPreview() = ElementPreview {
|
|||
showCursor = false,
|
||||
playbackProgress = 0.5f,
|
||||
onSeek = {},
|
||||
waveform = aWaveForm().toPersistentList(),
|
||||
waveform = aWaveForm().toImmutableList(),
|
||||
)
|
||||
WaveformPlaybackView(
|
||||
modifier = Modifier.height(34.dp),
|
||||
showCursor = true,
|
||||
playbackProgress = 0.5f,
|
||||
onSeek = {},
|
||||
waveform = List(1024) { it / 1024f }.toPersistentList(),
|
||||
waveform = List(1024) { it / 1024f }.toImmutableList(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -215,7 +215,7 @@ private fun ImmutableList<Float>.normalisedData(maxSamplesCount: Int): Immutable
|
|||
this
|
||||
}
|
||||
|
||||
return result.toPersistentList()
|
||||
return result.toImmutableList()
|
||||
}
|
||||
|
||||
fun aWaveForm(): List<Float> {
|
||||
|
|
|
|||
|
|
@ -28,14 +28,14 @@ import io.element.android.libraries.designsystem.preview.PreviewsDayNight
|
|||
import io.element.android.libraries.designsystem.theme.components.Icon
|
||||
import io.element.android.libraries.designsystem.theme.components.Text
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.toPersistentList
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
|
||||
internal class CompoundIconChunkProvider : PreviewParameterProvider<IconChunk> {
|
||||
override val values: Sequence<IconChunk>
|
||||
get() {
|
||||
val chunks = CompoundIcons.allResIds.chunked(36)
|
||||
return chunks.mapIndexed { index, chunk ->
|
||||
IconChunk(index = index + 1, total = chunks.size, icons = chunk.toPersistentList())
|
||||
IconChunk(index = index + 1, total = chunks.size, icons = chunk.toImmutableList())
|
||||
}
|
||||
.asSequence()
|
||||
}
|
||||
|
|
@ -46,7 +46,7 @@ internal class OtherIconChunkProvider : PreviewParameterProvider<IconChunk> {
|
|||
get() {
|
||||
val chunks = iconsOther.chunked(36)
|
||||
return chunks.mapIndexed { index, chunk ->
|
||||
IconChunk(index = index + 1, total = chunks.size, icons = chunk.toPersistentList())
|
||||
IconChunk(index = index + 1, total = chunks.size, icons = chunk.toImmutableList())
|
||||
}
|
||||
.asSequence()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue