From 5d91697be0c66ae293c71ee6f87b7626b3d2ea58 Mon Sep 17 00:00:00 2001 From: ganfra Date: Thu, 14 Dec 2023 13:13:11 +0100 Subject: [PATCH] Fix tests and warnings --- .../impl/timeline/TimelinePresenterTest.kt | 4 ++-- .../features/poll/impl/history/PollHistoryView.kt | 4 ++-- .../matrix/api/timeline/MatrixTimeline.kt | 14 +++++++++++--- .../matrix/impl/timeline/AsyncMatrixTimeline.kt | 2 +- .../matrix/impl/timeline/RustMatrixTimeline.kt | 2 +- .../TimelineEncryptedHistoryPostProcessorTest.kt | 2 +- 6 files changed, 18 insertions(+), 10 deletions(-) diff --git a/features/messages/impl/src/test/kotlin/io/element/android/features/messages/impl/timeline/TimelinePresenterTest.kt b/features/messages/impl/src/test/kotlin/io/element/android/features/messages/impl/timeline/TimelinePresenterTest.kt index c07286dddc..4316750a6a 100644 --- a/features/messages/impl/src/test/kotlin/io/element/android/features/messages/impl/timeline/TimelinePresenterTest.kt +++ b/features/messages/impl/src/test/kotlin/io/element/android/features/messages/impl/timeline/TimelinePresenterTest.kt @@ -43,9 +43,9 @@ import io.element.android.libraries.matrix.api.timeline.item.virtual.VirtualTime import io.element.android.libraries.matrix.test.AN_EVENT_ID import io.element.android.libraries.matrix.test.encryption.FakeEncryptionService import io.element.android.libraries.matrix.test.room.FakeMatrixRoom -import io.element.android.libraries.matrix.test.room.aMessageContent -import io.element.android.libraries.matrix.test.room.anEventTimelineItem import io.element.android.libraries.matrix.test.timeline.FakeMatrixTimeline +import io.element.android.libraries.matrix.test.timeline.aMessageContent +import io.element.android.libraries.matrix.test.timeline.anEventTimelineItem import io.element.android.libraries.matrix.test.verification.FakeSessionVerificationService import io.element.android.libraries.matrix.ui.components.aMatrixUserList import io.element.android.tests.testutils.WarmUpRule diff --git a/features/poll/impl/src/main/kotlin/io/element/android/features/poll/impl/history/PollHistoryView.kt b/features/poll/impl/src/main/kotlin/io/element/android/features/poll/impl/history/PollHistoryView.kt index 3b22eed41a..19ca239725 100644 --- a/features/poll/impl/src/main/kotlin/io/element/android/features/poll/impl/history/PollHistoryView.kt +++ b/features/poll/impl/src/main/kotlin/io/element/android/features/poll/impl/history/PollHistoryView.kt @@ -64,9 +64,9 @@ import kotlinx.collections.immutable.ImmutableList @Composable fun PollHistoryView( state: PollHistoryState, - modifier: Modifier = Modifier, onEditPoll: (EventId) -> Unit, goBack: () -> Unit, + modifier: Modifier = Modifier, ) { fun onLoadMore() { @@ -118,7 +118,7 @@ fun PollHistoryView( HorizontalPager( state = pagerState, userScrollEnabled = false, - modifier = modifier.fillMaxSize() + modifier = Modifier.fillMaxSize() ) { page -> val filter = PollHistoryFilter.entries[page] val pollHistoryItems = state.pollHistoryForFilter(filter) diff --git a/libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/timeline/MatrixTimeline.kt b/libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/timeline/MatrixTimeline.kt index 7a43d1079f..6c1433027b 100644 --- a/libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/timeline/MatrixTimeline.kt +++ b/libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/timeline/MatrixTimeline.kt @@ -23,11 +23,19 @@ import kotlinx.coroutines.flow.StateFlow interface MatrixTimeline : AutoCloseable { data class PaginationState( - val isBackPaginating: Boolean = false, - val hasMoreToLoadBackwards: Boolean = true, - val beginningOfRoomReached: Boolean = false, + val isBackPaginating: Boolean, + val hasMoreToLoadBackwards: Boolean, + val beginningOfRoomReached: Boolean, ) { val canBackPaginate = !isBackPaginating && hasMoreToLoadBackwards + + companion object { + val Initial = PaginationState( + isBackPaginating = false, + hasMoreToLoadBackwards = true, + beginningOfRoomReached = false + ) + } } val paginationState: StateFlow diff --git a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/timeline/AsyncMatrixTimeline.kt b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/timeline/AsyncMatrixTimeline.kt index 5f7636eaa9..fcc9a2a257 100644 --- a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/timeline/AsyncMatrixTimeline.kt +++ b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/timeline/AsyncMatrixTimeline.kt @@ -47,7 +47,7 @@ class AsyncMatrixTimeline( MutableStateFlow(emptyList()) private val _paginationState = MutableStateFlow( - MatrixTimeline.PaginationState() + MatrixTimeline.PaginationState.Initial ) private val timeline = coroutineScope.async(context = dispatcher, start = CoroutineStart.LAZY) { timelineProvider() diff --git a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/timeline/RustMatrixTimeline.kt b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/timeline/RustMatrixTimeline.kt index 3995392cbc..ebe6cfccfb 100644 --- a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/timeline/RustMatrixTimeline.kt +++ b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/timeline/RustMatrixTimeline.kt @@ -72,7 +72,7 @@ class RustMatrixTimeline( MutableStateFlow(emptyList()) private val _paginationState = MutableStateFlow( - MatrixTimeline.PaginationState() + MatrixTimeline.PaginationState.Initial ) private val encryptedHistoryPostProcessor = TimelineEncryptedHistoryPostProcessor( diff --git a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/timeline/postprocessor/TimelineEncryptedHistoryPostProcessorTest.kt b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/timeline/postprocessor/TimelineEncryptedHistoryPostProcessorTest.kt index cf5c3682c2..029ae2336a 100644 --- a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/timeline/postprocessor/TimelineEncryptedHistoryPostProcessorTest.kt +++ b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/timeline/postprocessor/TimelineEncryptedHistoryPostProcessorTest.kt @@ -20,7 +20,7 @@ import com.google.common.truth.Truth.assertThat import io.element.android.libraries.matrix.api.timeline.MatrixTimeline import io.element.android.libraries.matrix.api.timeline.MatrixTimelineItem import io.element.android.libraries.matrix.api.timeline.item.virtual.VirtualTimelineItem -import io.element.android.libraries.matrix.test.room.anEventTimelineItem +import io.element.android.libraries.matrix.test.timeline.anEventTimelineItem import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.test.StandardTestDispatcher import kotlinx.coroutines.test.TestScope