Skip to content

Commit

Permalink
feat:TOP-106 Local에 캐싱된 Topic이 없는 경우 에러 처리
Browse files Browse the repository at this point in the history
  • Loading branch information
cwj-c committed Jan 5, 2025
1 parent 171d094 commit 3ef14ee
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,23 @@ fun DailyUserCardResponse.UserInfo.IdealTypeResponse.toModel(): IdealTypeModel {
return IdealTypeModel(
title = name,
key = idx,
emojiCode = emojiCode
emojiCode = if (emojiCode.startsWith("U+")) {
emojiCode.removePrefix("U+")
} else {
emojiCode
}
)
}

fun DailyUserCardResponse.UserInfo.InterestResponse.toModel(): InterestModel {
return InterestModel(
title = name,
key = idx,
emojiCode = emojiCode
emojiCode = if (emojiCode.startsWith("U+")) {
emojiCode.removePrefix("U+")
} else {
emojiCode
}
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ class FetchToHotStateUseCase(
size: Int = 10
): Result<ToHotStateModel> {
return kotlin.runCatching {
val topicCachedFromLocal = topicRepository.fetchDailyTopicFromLocal()
val topic = if (now > topicCachedFromLocal.topicResetTimeMill) {
val topicCachedFromLocal = runCatching {
topicRepository.fetchDailyTopicFromLocal()
}.getOrNull()
val topic = if (
topicCachedFromLocal == null || now > topicCachedFromLocal.topicResetTimeMill
) {
fetchDailyTopicListUseCase().getOrThrow()
} else {
topicCachedFromLocal
Expand Down

0 comments on commit 3ef14ee

Please sign in to comment.