mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-03 16:10:00 +00:00
RoomList: extend a bit the range of SS window
This commit is contained in:
+8
-1
@@ -20,6 +20,8 @@ import kotlinx.coroutines.flow.flowOn
|
|||||||
import kotlinx.coroutines.flow.map
|
import kotlinx.coroutines.flow.map
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
|
private const val extendedRangeSize = 40
|
||||||
|
|
||||||
class RoomListViewModel(
|
class RoomListViewModel(
|
||||||
private val client: MatrixClient,
|
private val client: MatrixClient,
|
||||||
initialState: RoomListViewState
|
initialState: RoomListViewState
|
||||||
@@ -69,7 +71,12 @@ class RoomListViewModel(
|
|||||||
fun updateVisibleRange(range: IntRange) {
|
fun updateVisibleRange(range: IntRange) {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
if (range.isEmpty()) return@launch
|
if (range.isEmpty()) return@launch
|
||||||
client.roomSummaryDataSource().setSlidingSyncRange(range)
|
val midExtendedRangeSize = extendedRangeSize / 2
|
||||||
|
val extendedRangeStart = (range.first - midExtendedRangeSize).coerceAtLeast(0)
|
||||||
|
// Safe to give bigger size than room list
|
||||||
|
val extendedRangeEnd = range.last + midExtendedRangeSize
|
||||||
|
val extendedRange = IntRange(extendedRangeStart, extendedRangeEnd)
|
||||||
|
client.roomSummaryDataSource().setSlidingSyncRange(extendedRange)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ class MatrixClient internal constructor(
|
|||||||
)
|
)
|
||||||
.name(name = "HomeScreenView")
|
.name(name = "HomeScreenView")
|
||||||
.syncMode(mode = SlidingSyncMode.SELECTIVE)
|
.syncMode(mode = SlidingSyncMode.SELECTIVE)
|
||||||
.addRange(0u, 10u)
|
.addRange(0u, 30u)
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
private val slidingSync = client
|
private val slidingSync = client
|
||||||
|
|||||||
Reference in New Issue
Block a user