mirror of
https://github.com/usetrmnl/trmnl-android.git
synced 2026-04-29 13:35:26 -07:00
Merge pull request #177 from usetrmnl/refactor-and-fixes
Refactor and fixes
This commit is contained in:
@@ -19,6 +19,6 @@ class RepositoryConfigProvider
|
||||
get() {
|
||||
// To change this value, update the `buildConfigField` in the app's build.gradle file
|
||||
// Or, change the value here for local development. Do not commit this change.
|
||||
return BuildConfig.USE_FAKE_API
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,7 +218,7 @@ class TrmnlDisplayRepository
|
||||
failure: ApiResult.Failure<Unit>,
|
||||
): TrmnlDisplayInfo =
|
||||
TrmnlDisplayInfo(
|
||||
status = HTTP_500,
|
||||
status = (failure as? ApiResult.Failure.HttpFailure)?.code ?: HTTP_500,
|
||||
trmnlDeviceType = trmnlDeviceConfig.type,
|
||||
imageUrl = "",
|
||||
imageFileName = "",
|
||||
|
||||
@@ -87,6 +87,8 @@ class TrmnlImageRefreshWorker(
|
||||
|
||||
// Check for rate limit errors (HTTP 429) - should retry with exponential backoff
|
||||
if (trmnlDisplayInfo.status.isRateLimitError()) {
|
||||
// NOTE: This usually happens for current display API. See details below:
|
||||
// - https://discord.com/channels/1281055965508141100/1336424981495676978/1429827943902744618
|
||||
Timber.tag(TAG).w("Rate limit exceeded (HTTP 429), will retry with exponential backoff")
|
||||
refreshLogManager.addFailureLog(
|
||||
error = "Rate limit exceeded (HTTP 429) - Too many requests. Will retry automatically.",
|
||||
|
||||
@@ -501,7 +501,7 @@ class TrmnlDisplayRepositoryTest {
|
||||
val result = repository.getNextDisplayData(testDeviceConfig)
|
||||
|
||||
// Assert
|
||||
assertThat(result.status).isEqualTo(500)
|
||||
assertThat(result.status).isEqualTo(429)
|
||||
assertThat(result.error).contains("HTTP failure: 429")
|
||||
assertThat(result.trmnlDeviceType).isEqualTo(TrmnlDeviceType.TRMNL)
|
||||
// Verify HTTP metadata is extracted
|
||||
|
||||
Reference in New Issue
Block a user