From 19e1a6ac9bfffbd45488bc11fb18a7b5a43e6bcd Mon Sep 17 00:00:00 2001 From: rainxchzed Date: Mon, 4 May 2026 18:04:01 +0500 Subject: [PATCH 1/2] fix(details): suppress sign-in hint on rate-limit toast when user already signed in --- .../githubstore/app/di/ViewModelsModule.kt | 1 + .../details/presentation/DetailsViewModel.kt | 15 ++++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/composeApp/src/commonMain/kotlin/zed/rainxch/githubstore/app/di/ViewModelsModule.kt b/composeApp/src/commonMain/kotlin/zed/rainxch/githubstore/app/di/ViewModelsModule.kt index 10982d118..3774d903c 100644 --- a/composeApp/src/commonMain/kotlin/zed/rainxch/githubstore/app/di/ViewModelsModule.kt +++ b/composeApp/src/commonMain/kotlin/zed/rainxch/githubstore/app/di/ViewModelsModule.kt @@ -58,6 +58,7 @@ val viewModelsModule = telemetryRepository = get(), externalImportRepository = get(), apkInspector = get(), + authenticationState = get(), ) } viewModelOf(::DeveloperProfileViewModel) diff --git a/feature/details/presentation/src/commonMain/kotlin/zed/rainxch/details/presentation/DetailsViewModel.kt b/feature/details/presentation/src/commonMain/kotlin/zed/rainxch/details/presentation/DetailsViewModel.kt index 427a67c43..e6ffa00db 100644 --- a/feature/details/presentation/src/commonMain/kotlin/zed/rainxch/details/presentation/DetailsViewModel.kt +++ b/feature/details/presentation/src/commonMain/kotlin/zed/rainxch/details/presentation/DetailsViewModel.kt @@ -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 @@ -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( From c9737fb0f4d02663545b62bf7c6a07141ee19b1c Mon Sep 17 00:00:00 2001 From: rainxchzed Date: Mon, 4 May 2026 18:08:56 +0500 Subject: [PATCH 2/2] fix(installed-apps): route fetchReleaseWindow through backend pool to stop cold-start rate-limit dialog --- .../zed/rainxch/core/data/di/SharedModule.kt | 1 + .../repository/InstalledAppsRepositoryImpl.kt | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/core/data/src/commonMain/kotlin/zed/rainxch/core/data/di/SharedModule.kt b/core/data/src/commonMain/kotlin/zed/rainxch/core/data/di/SharedModule.kt index b108f6d5d..fc56f9c2e 100644 --- a/core/data/src/commonMain/kotlin/zed/rainxch/core/data/di/SharedModule.kt +++ b/core/data/src/commonMain/kotlin/zed/rainxch/core/data/di/SharedModule.kt @@ -123,6 +123,7 @@ val coreModule = historyDao = get(), installer = get(), clientProvider = get(), + backendApiClient = get(), ) } diff --git a/core/data/src/commonMain/kotlin/zed/rainxch/core/data/repository/InstalledAppsRepositoryImpl.kt b/core/data/src/commonMain/kotlin/zed/rainxch/core/data/repository/InstalledAppsRepositoryImpl.kt index 7bcfe2f17..06e8c29f3 100644 --- a/core/data/src/commonMain/kotlin/zed/rainxch/core/data/repository/InstalledAppsRepositoryImpl.kt +++ b/core/data/src/commonMain/kotlin/zed/rainxch/core/data/repository/InstalledAppsRepositoryImpl.kt @@ -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]) @@ -126,6 +127,26 @@ class InstalledAppsRepositoryImpl( repo: String, includePreReleases: Boolean, ): List { + 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