Skip to content

Commit

Permalink
[FIX] 커뮤니티 게시글이 없을 때 null 처리 (#954)
Browse files Browse the repository at this point in the history
  • Loading branch information
kimhyeing committed Aug 6, 2024
1 parent 56f7105 commit e870fcb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,17 @@ class CommunityByCommunityPagingSource @Inject constructor(
limit = PAGE_LIMIT
).data

val items = response?.posts

LoadResult.Page(
data = items!!,
prevKey = if (page <= 1) null else (page - 1),
nextKey = if (response.isLastPage) null else (page + 1)
response?.let {
val items = it.posts
LoadResult.Page(
data = items,
prevKey = if (page <= 1) null else (page - 1),
nextKey = if (it.isLastPage) null else (page + 1)
)
} ?: LoadResult.Page(
data = emptyList(),
prevKey = null,
nextKey = null
)
} catch (e: Exception) {
Log.e("CommunityByCommunityPagingSource", "error : $e")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,17 @@ class CommunityPagingSource @Inject constructor(
limit = PAGE_LIMIT
).data

val items = response?.posts

LoadResult.Page(
data = items!!,
prevKey = if (page <= 1) null else (page - 1),
nextKey = if (response.isLastPage) null else (page + 1)
response?.let {
val items = it.posts
LoadResult.Page(
data = items,
prevKey = if (page <= 1) null else (page - 1),
nextKey = if (response.isLastPage) null else (page + 1)
)
} ?: LoadResult.Page(
data = emptyList(),
prevKey = null,
nextKey = null
)
} catch (e: Exception) {
Log.e("CommunityPagingSource", "error : $e")
Expand Down

0 comments on commit e870fcb

Please sign in to comment.