Remove enableplaceholders config option

This commit is contained in:
Matthieu 2021-11-28 19:00:18 +01:00
parent f22cd47452
commit 58b668e09a
8 changed files with 23 additions and 42 deletions

View File

@ -48,8 +48,7 @@ class FeedContentRepository<T: FeedContentDatabase> @ExperimentalPagingApi
return Pager(
config = PagingConfig(initialLoadSize = NETWORK_PAGE_SIZE,
pageSize = NETWORK_PAGE_SIZE,
enablePlaceholders = false,
prefetchDistance = 50
prefetchDistance = 20
),
remoteMediator = mediator,
pagingSourceFactory = pagingSourceFactory

View File

@ -41,18 +41,14 @@ class NotificationsRemoteMediator @Inject constructor(
override suspend fun load(loadType: LoadType, state: PagingState<Int, Notification>): MediatorResult {
val (max_id, min_id) = when (loadType) {
LoadType.REFRESH -> {
Pair<String?, String?>(null, null)
}
val maxId = when (loadType) {
LoadType.REFRESH -> null
LoadType.PREPEND -> {
//No prepend for the moment, might be nice to add later
return MediatorResult.Success(endOfPaginationReached = true)
}
LoadType.APPEND -> {
Pair<String?, String?>(state.lastItemOrNull()?.id, null)
}
LoadType.APPEND -> state.lastItemOrNull()?.id
?: return MediatorResult.Success(endOfPaginationReached = true)
}
try {
@ -61,10 +57,9 @@ class NotificationsRemoteMediator @Inject constructor(
val api = apiHolder.api ?: apiHolder.setToCurrentUser()
val apiResponse = api.notifications(
max_id = max_id,
min_id = min_id,
limit = state.config.pageSize.toString(),
)
max_id = maxId,
limit = state.config.pageSize.toString()
)
apiResponse.forEach{it.user_id = user.user_id; it.instance_uri = user.instance_uri}

View File

@ -26,18 +26,14 @@ class HomeFeedRemoteMediator @Inject constructor(
override suspend fun load(loadType: LoadType, state: PagingState<Int, HomeStatusDatabaseEntity>): MediatorResult {
val (max_id, min_id) = when (loadType) {
LoadType.REFRESH -> {
Pair<String?, String?>(null, null)
}
val maxId = when (loadType) {
LoadType.REFRESH -> null
LoadType.PREPEND -> {
//No prepend for the moment, might be nice to add later
return MediatorResult.Success(endOfPaginationReached = true)
}
LoadType.APPEND -> {
Pair<String?, String?>(state.lastItemOrNull()?.id, null)
}
LoadType.APPEND -> state.lastItemOrNull()?.id
?: return MediatorResult.Success(endOfPaginationReached = true)
}
try {
@ -46,8 +42,7 @@ class HomeFeedRemoteMediator @Inject constructor(
val api = apiHolder.api ?: apiHolder.setToCurrentUser()
val apiResponse = api.timelineHome(
max_id= max_id,
min_id = min_id, limit = state.config.pageSize.toString()
max_id= maxId, limit = state.config.pageSize.toString()
)
val dbObjects = apiResponse.map{

View File

@ -41,18 +41,14 @@ class PublicFeedRemoteMediator @Inject constructor(
override suspend fun load(loadType: LoadType, state: PagingState<Int, PublicFeedStatusDatabaseEntity>): MediatorResult {
val (max_id, min_id) = when (loadType) {
LoadType.REFRESH -> {
Pair<String?, String?>(null, null)
}
val maxId = when (loadType) {
LoadType.REFRESH -> null
LoadType.PREPEND -> {
//No prepend for the moment, might be nice to add later
return MediatorResult.Success(endOfPaginationReached = true)
}
LoadType.APPEND -> {
Pair<String?, String?>(state.lastItemOrNull()?.id, null)
}
LoadType.APPEND -> state.lastItemOrNull()?.id
?: return MediatorResult.Success(endOfPaginationReached = true)
}
try {
@ -61,8 +57,7 @@ class PublicFeedRemoteMediator @Inject constructor(
val api = apiHolder.api ?: apiHolder.setToCurrentUser()
val apiResponse = api.timelinePublic(
max_id = max_id,
min_id = min_id,
max_id = maxId,
limit = state.config.pageSize.toString(),
)

View File

@ -21,8 +21,7 @@ class FollowersContentRepository @ExperimentalPagingApi
return Pager(
config = PagingConfig(
initialLoadSize = NETWORK_PAGE_SIZE,
pageSize = NETWORK_PAGE_SIZE,
enablePlaceholders = false),
pageSize = NETWORK_PAGE_SIZE),
pagingSourceFactory = {
FollowersPagingSource(api, accountId, following)
}

View File

@ -24,8 +24,8 @@ class HashTagContentRepository @ExperimentalPagingApi
return Pager(
config = PagingConfig(
initialLoadSize = NETWORK_PAGE_SIZE,
pageSize = NETWORK_PAGE_SIZE,
enablePlaceholders = false),
pageSize = NETWORK_PAGE_SIZE
),
pagingSourceFactory = {
HashTagPagingSource(api, hashtag)
}

View File

@ -19,8 +19,7 @@ class ProfileContentRepository @ExperimentalPagingApi
return Pager(
config = PagingConfig(
initialLoadSize = NETWORK_PAGE_SIZE,
pageSize = NETWORK_PAGE_SIZE,
enablePlaceholders = false),
pageSize = NETWORK_PAGE_SIZE),
pagingSourceFactory = {
ProfilePagingSource(api, accountId)
}

View File

@ -28,8 +28,7 @@ class SearchContentRepository<T: FeedContent> @ExperimentalPagingApi
return Pager(
config = PagingConfig(
initialLoadSize = NETWORK_PAGE_SIZE,
pageSize = NETWORK_PAGE_SIZE,
enablePlaceholders = false),
pageSize = NETWORK_PAGE_SIZE),
pagingSourceFactory = {
SearchPagingSource<T>(api, query, type)
}