Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ data class SearchContentsResponseDto(
@Serializable
data class Content(
@SerialName("id")
val id: String,
val id: String? = null,
@SerialName("title")
val title: String,
val title: String? = null,
@SerialName("author")
val author: String,
val author: String? = null,
@SerialName("posterUrl")
val posterUrl: String,
val posterUrl: String? = null,
@SerialName("year")
val year: Int,
val year: Int? = null,
)

@Serializable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,20 @@ import kotlinx.collections.immutable.toImmutableList

fun SearchContentsResponseDto.toModel(): SearchContentListModel {
return SearchContentListModel(
contents = this.data.map { it.toModel() }.toImmutableList(),
// id 없는 항목은 LazyGrid의 key로 쓸 수 없어 식별 불가능하므로 제외
contents = this.data.mapNotNull { it.toModel() }.toImmutableList(),
nextCursor = this.meta?.nextCursor,
)
}

private fun SearchContentsResponseDto.Content.toModel(): SearchContentItemModel{
private fun SearchContentsResponseDto.Content.toModel(): SearchContentItemModel? {
val id = id ?: return null
return SearchContentItemModel(
id = id,
title = title,
author = author,
posterUrl = posterUrl,
year = year
title = title.orEmpty(),
author = author.orEmpty(),
posterUrl = posterUrl.orEmpty(),
year = year ?: 0,
)
}

Expand Down
Loading