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 @@ -58,6 +58,7 @@ val viewModelsModule =
telemetryRepository = get(),
externalImportRepository = get(),
apkInspector = get(),
authenticationState = get(),
)
}
viewModelOf(::DeveloperProfileViewModel)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ val coreModule =
historyDao = get(),
installer = get(),
clientProvider = get(),
backendApiClient = get(),
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class InstalledAppsRepositoryImpl(
private val historyDao: UpdateHistoryDao,
private val installer: Installer,
private val clientProvider: GitHubClientProvider,
private val backendApiClient: zed.rainxch.core.data.network.BackendApiClient,
) : InstalledAppsRepository {
// Reads the current Ktor client at every call site so any proxy
// change (ProxyManager rebuilds the client via [clientProvider])
Expand Down Expand Up @@ -126,6 +127,26 @@ class InstalledAppsRepositoryImpl(
repo: String,
includePreReleases: Boolean,
): List<GithubRelease> {
val backendResult = backendApiClient.getReleases(owner, repo, perPage = RELEASE_WINDOW)
val backendReleases = backendResult.fold(
onSuccess = { it },
onFailure = { error ->
if (!zed.rainxch.core.data.network.shouldFallbackToGithubOrRethrow(error)) {
return emptyList()
}
null
},
)
if (backendReleases != null) {
return backendReleases
.asSequence()
.filter { it.draft != true }
.sortedByDescending { it.publishedAt ?: it.createdAt ?: "" }
.map { it.toDomain() }
.filter { includePreReleases || !it.isEffectivelyPreRelease() }
.toList()
}

return try {
val releases =
httpClient
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ class DetailsViewModel(
private val telemetryRepository: TelemetryRepository,
private val externalImportRepository: ExternalImportRepository,
private val apkInspector: ApkInspector,
private val authenticationState: zed.rainxch.core.domain.repository.AuthenticationState,
) : ViewModel() {
private var hasLoadedInitialData = false
private var currentDownloadJob: Job? = null
Expand Down Expand Up @@ -2572,12 +2573,16 @@ class DetailsViewModel(
} catch (e: RateLimitException) {
logger.error("Rate limited: ${e.message}")
val seconds = e.rateLimitInfo.timeUntilReset().inWholeSeconds
val message = if (seconds > 0L) {
getString(Res.string.rate_limit_exceeded_retry_in, seconds.toInt()) + " " +
getString(Res.string.rate_limit_exceeded_signin_hint)
val signedIn = authenticationState.isCurrentlyUserLoggedIn()
val base = if (seconds > 0L) {
getString(Res.string.rate_limit_exceeded_retry_in, seconds.toInt())
} else {
getString(Res.string.rate_limit_exceeded) + " " +
getString(Res.string.rate_limit_exceeded_signin_hint)
getString(Res.string.rate_limit_exceeded)
}
val message = if (!signedIn) {
base + " " + getString(Res.string.rate_limit_exceeded_signin_hint)
} else {
base
}
_state.value =
_state.value.copy(
Expand Down