mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-15 01:35:07 +08:00
Renaming API field and adding more doc to make things clearer
This commit is contained in:
parent
fc26d61305
commit
c7d3e1926f
@ -20,7 +20,20 @@ package org.matrix.android.sdk.api.session.room.poll
|
||||
* Represent the status of the loaded polls for a room.
|
||||
*/
|
||||
data class LoadedPollsStatus(
|
||||
/**
|
||||
* Indicate whether more polls can be loaded from timeline.
|
||||
* A false value would mean the start of the timeline has been reached.
|
||||
*/
|
||||
val canLoadMore: Boolean,
|
||||
val nbSyncedDays: Int,
|
||||
|
||||
/**
|
||||
* Number of days of timeline events currently synced (fetched and stored in local).
|
||||
*/
|
||||
val daysSynced: Int,
|
||||
|
||||
/**
|
||||
* Indicate whether a sync of timeline events has been completely done in backward. It would
|
||||
* mean timeline events have been synced for at least a number of days defined by [PollHistoryService.loadingPeriodInDays].
|
||||
*/
|
||||
val hasCompletedASyncBackward: Boolean,
|
||||
)
|
||||
|
@ -24,6 +24,9 @@ import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent
|
||||
*/
|
||||
interface PollHistoryService {
|
||||
|
||||
/**
|
||||
* The number of days covered when requesting to load more polls.
|
||||
*/
|
||||
val loadingPeriodInDays: Int
|
||||
|
||||
/**
|
||||
|
@ -43,7 +43,7 @@ internal class DefaultGetLoadedPollsStatusTask @Inject constructor(
|
||||
.copy()
|
||||
LoadedPollsStatus(
|
||||
canLoadMore = status.isEndOfPollsBackward.not(),
|
||||
nbSyncedDays = status.getNbSyncedDays(params.currentTimestampMs),
|
||||
daysSynced = status.getNbSyncedDays(params.currentTimestampMs),
|
||||
hasCompletedASyncBackward = status.hasCompletedASyncBackward,
|
||||
)
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ internal class DefaultLoadMorePollsTask @Inject constructor(
|
||||
|
||||
return LoadedPollsStatus(
|
||||
canLoadMore = currentPollHistoryStatus.isEndOfPollsBackward.not(),
|
||||
nbSyncedDays = currentPollHistoryStatus.getNbSyncedDays(params.currentTimestampMs),
|
||||
daysSynced = currentPollHistoryStatus.getNbSyncedDays(params.currentTimestampMs),
|
||||
hasCompletedASyncBackward = currentPollHistoryStatus.hasCompletedASyncBackward,
|
||||
)
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ class RoomPollsViewModel @AssistedInject constructor(
|
||||
setState {
|
||||
copy(
|
||||
canLoadMore = loadedPollsStatus.canLoadMore,
|
||||
nbSyncedDays = loadedPollsStatus.nbSyncedDays,
|
||||
nbSyncedDays = loadedPollsStatus.daysSynced,
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -100,7 +100,7 @@ class RoomPollsViewModel @AssistedInject constructor(
|
||||
setState {
|
||||
copy(
|
||||
canLoadMore = status.canLoadMore,
|
||||
nbSyncedDays = status.nbSyncedDays,
|
||||
nbSyncedDays = status.daysSynced,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ class RoomPollsViewModelTest {
|
||||
val expectedViewState = initialState.copy(
|
||||
polls = listOf(aPollSummary),
|
||||
canLoadMore = loadedPollsStatus.canLoadMore,
|
||||
nbSyncedDays = loadedPollsStatus.nbSyncedDays,
|
||||
nbSyncedDays = loadedPollsStatus.daysSynced,
|
||||
)
|
||||
|
||||
// When
|
||||
@ -135,7 +135,7 @@ class RoomPollsViewModelTest {
|
||||
val stateAfterInit = initialState.copy(
|
||||
polls = emptyList(),
|
||||
canLoadMore = loadedPollsStatus.canLoadMore,
|
||||
nbSyncedDays = loadedPollsStatus.nbSyncedDays,
|
||||
nbSyncedDays = loadedPollsStatus.daysSynced,
|
||||
)
|
||||
|
||||
// When
|
||||
@ -147,7 +147,7 @@ class RoomPollsViewModelTest {
|
||||
.assertStatesChanges(
|
||||
stateAfterInit,
|
||||
{ copy(isLoadingMore = true) },
|
||||
{ copy(canLoadMore = newLoadedPollsStatus.canLoadMore, nbSyncedDays = newLoadedPollsStatus.nbSyncedDays) },
|
||||
{ copy(canLoadMore = newLoadedPollsStatus.canLoadMore, nbSyncedDays = newLoadedPollsStatus.daysSynced) },
|
||||
{ copy(isLoadingMore = false) },
|
||||
)
|
||||
.finish()
|
||||
@ -181,7 +181,7 @@ class RoomPollsViewModelTest {
|
||||
private fun givenALoadedPollsStatus(canLoadMore: Boolean = true, nbSyncedDays: Int = 10) =
|
||||
LoadedPollsStatus(
|
||||
canLoadMore = canLoadMore,
|
||||
nbSyncedDays = nbSyncedDays,
|
||||
daysSynced = nbSyncedDays,
|
||||
hasCompletedASyncBackward = false,
|
||||
)
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ internal class RoomPollDataSourceTest {
|
||||
|
||||
private fun givenALoadedPollsStatus() = LoadedPollsStatus(
|
||||
canLoadMore = true,
|
||||
nbSyncedDays = 10,
|
||||
daysSynced = 10,
|
||||
hasCompletedASyncBackward = true,
|
||||
)
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ class RoomPollRepositoryTest {
|
||||
// Given
|
||||
val expectedStatus = LoadedPollsStatus(
|
||||
canLoadMore = true,
|
||||
nbSyncedDays = 10,
|
||||
daysSynced = 10,
|
||||
hasCompletedASyncBackward = false,
|
||||
)
|
||||
coEvery { fakeRoomPollDataSource.getLoadedPollsStatus(A_ROOM_ID) } returns expectedStatus
|
||||
|
@ -39,7 +39,7 @@ class GetLoadedPollsStatusUseCaseTest {
|
||||
val aRoomId = "roomId"
|
||||
val expectedStatus = LoadedPollsStatus(
|
||||
canLoadMore = true,
|
||||
nbSyncedDays = 10,
|
||||
daysSynced = 10,
|
||||
hasCompletedASyncBackward = true,
|
||||
)
|
||||
coEvery { fakeRoomPollRepository.getLoadedPollsStatus(aRoomId) } returns expectedStatus
|
||||
|
@ -39,7 +39,7 @@ class LoadMorePollsUseCaseTest {
|
||||
val aRoomId = "roomId"
|
||||
val loadedPollsStatus = LoadedPollsStatus(
|
||||
canLoadMore = true,
|
||||
nbSyncedDays = 10,
|
||||
daysSynced = 10,
|
||||
hasCompletedASyncBackward = true,
|
||||
)
|
||||
coEvery { fakeRoomPollRepository.loadMorePolls(aRoomId) } returns loadedPollsStatus
|
||||
|
@ -45,7 +45,7 @@ class SyncPollsUseCaseTest {
|
||||
val aRoomId = "roomId"
|
||||
val aLoadedStatus = LoadedPollsStatus(
|
||||
canLoadMore = true,
|
||||
nbSyncedDays = 10,
|
||||
daysSynced = 10,
|
||||
hasCompletedASyncBackward = true,
|
||||
)
|
||||
coJustRun { fakeRoomPollRepository.syncPolls(aRoomId) }
|
||||
@ -71,12 +71,12 @@ class SyncPollsUseCaseTest {
|
||||
val aRoomId = "roomId"
|
||||
val aLoadedStatus = LoadedPollsStatus(
|
||||
canLoadMore = true,
|
||||
nbSyncedDays = 10,
|
||||
daysSynced = 10,
|
||||
hasCompletedASyncBackward = false,
|
||||
)
|
||||
val anUpdatedLoadedStatus = LoadedPollsStatus(
|
||||
canLoadMore = true,
|
||||
nbSyncedDays = 10,
|
||||
daysSynced = 10,
|
||||
hasCompletedASyncBackward = true,
|
||||
)
|
||||
coJustRun { fakeRoomPollRepository.syncPolls(aRoomId) }
|
||||
|
Loading…
Reference in New Issue
Block a user