Skip to content

Commit

Permalink
처음에 반다라트가 1개일때 반다라트를 삭제했을 때, 새로운 반다라트가 생성되지 않고 무한 스켈레톤이 발생하는 문제 해결 (#80)
Browse files Browse the repository at this point in the history
* timeOutMillis 를 15_000가 아닌 3_000으로, 연결 재시도 횟수를 3번으로 변경

MaxTimeOutMills 15초 -> 9초

* 반다라트가 1개 일때, 반다라트를 삭제하고 다시 새로운 반다라트가 생성되지 않는 이슈 해결
  • Loading branch information
easyhooon committed Aug 22, 2023
1 parent 384c142 commit 518364b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import io.ktor.client.HttpClient
import io.ktor.client.engine.cio.CIO
import io.ktor.client.plugins.HttpTimeout
import io.ktor.client.engine.cio.endpoint
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
import io.ktor.client.plugins.defaultRequest
import io.ktor.client.plugins.logging.LogLevel
Expand All @@ -23,14 +23,23 @@ import kotlinx.coroutines.runBlocking
import kotlinx.serialization.json.Json
import timber.log.Timber

private const val MaxTimeoutMillis = 3000L
private const val MaxRetryCount = 3

@Module
@InstallIn(SingletonComponent::class)
internal object NetworkModule {

@Singleton
@Provides
fun provideKtorHttpClient(dataStoreProvider: DataStoreProvider): HttpClient {
return HttpClient(CIO) {
return HttpClient(engineFactory = CIO) {
engine {
endpoint {
connectTimeout = MaxTimeoutMillis
connectAttempts = MaxRetryCount
}
}
defaultRequest {
val guestLoginToken = runBlocking {
dataStoreProvider.getGuestLoginToken()
Expand All @@ -55,11 +64,6 @@ internal object NetworkModule {
}
level = LogLevel.ALL
}
install(HttpTimeout) {
socketTimeoutMillis = 15_000
requestTimeoutMillis = 15_000
connectTimeoutMillis = 15_000
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ class HomeViewModel @Inject constructor(
bandalartList = bandalartList,
error = null,
)

// 이전 반다라트 목록 상태 조회
val prevBandalartList = getPrevBandalartListUseCase()

Expand All @@ -148,9 +149,9 @@ class HomeViewModel @Inject constructor(
getBandalartDetail(bandalartKey)
return@launch
}

// 반다라트 목록이 존재하지 않을 경우, 새로운 반다라트를 생성
if (bandalartList.isEmpty()) {
_uiState.value = _uiState.value.copy(isNetworking = false)
createBandalart()
}
// 반다라트 목록이 존재할 경우
Expand Down

0 comments on commit 518364b

Please sign in to comment.