Breadcrumbs: limit number to 20

This commit is contained in:
Benoit Marty 2019-12-05 17:43:23 +01:00
parent 4ff12605e9
commit ad4d5e5c02
1 changed files with 4 additions and 1 deletions

View File

@ -23,6 +23,9 @@ import im.vector.matrix.android.internal.task.Task
import im.vector.matrix.android.internal.util.fetchCopied import im.vector.matrix.android.internal.util.fetchCopied
import javax.inject.Inject import javax.inject.Inject
// Use same arbitrary value than Riot-Web
private const val MAX_BREADCRUMBS_ROOMS_NUMBER = 20
internal interface UpdateBreadcrumbsTask : Task<UpdateBreadcrumbsTask.Params, Unit> { internal interface UpdateBreadcrumbsTask : Task<UpdateBreadcrumbsTask.Params, Unit> {
data class Params( data class Params(
// Last seen roomId // Last seen roomId
@ -50,7 +53,7 @@ internal class DefaultUpdateBreadcrumbsTask @Inject constructor(
bc.recentRoomIds.remove(params.roomId) bc.recentRoomIds.remove(params.roomId)
// Add the room at first position // Add the room at first position
bc.recentRoomIds.add(0, params.roomId) bc.recentRoomIds.add(0, params.roomId)
bc.recentRoomIds.toList() bc.recentRoomIds.take(MAX_BREADCRUMBS_ROOMS_NUMBER)
} else { } else {
listOf(params.roomId) listOf(params.roomId)
} }