Open
Conversation
This commit introduces the foundational support for GitLab as an alternative API source alongside GitHub. It refactors the authentication, data fetching, and state management systems to be platform-agnostic.
**Key Changes:**
* **Multi-Platform Authentication:**
* The authentication flow is now abstracted to handle both GitHub and GitLab, using a new `ApiPlatform` enum.
* Introduced `GitLabAuthApi` to handle GitLab's OAuth 2.0 device authorization grant flow.
* `TokenDataSource` and `TokenStore` are updated to manage tokens separately for each platform.
* The login UI now dynamically adapts to show "Sign in with GitLab" or "Sign in with GitHub".
* **Platform-Aware Data Fetching:**
* Repositories (`HomeRepository`, `SearchRepository`, `DetailsRepository`) and DI modules (`Koin`) are refactored to be platform-specific.
* Added network clients and data models (`GitLabProjectNetworkModel`) for interacting with the GitLab API.
* Created a mapper (`toGithubRepoNetworkModel`) to transform GitLab project data into a common `GithubRepoNetworkModel` format, allowing for consistent UI rendering.
* The Home screen can now fetch and display trending, new, and updated projects from GitLab.
* **State Management & UI:**
* Introduced a bottom navigation bar to switch between GitHub and GitLab content.
* `AppStateManager` and `MainViewModel` now track authentication status, rate limits, and the currently selected `ApiPlatform` separately.
* Rate limit dialogs are updated to be platform-aware, showing correct messages and triggering the appropriate login flow.
* Added a GitLab icon and integrated it into the UI.
* **Code Refactoring & Housekeeping:**
* Refactored Koin modules to use named qualifiers for platform-specific dependencies (e.g., `named("github")`, `named("gitlab")`).
* Moved several core services (like `Downloader`, `Installer`, `PackageMonitor`) from feature packages to a central `core/data/services` package for better project structure.
…ation This change introduces automatic OAuth token refreshing for GitLab to handle expiring access tokens, ensuring a more stable authenticated session. It also includes several fixes and improvements to make GitLab integration more robust and feature-complete. **Key Changes:** **Authentication:** - Implemented an `OAuthTokenRefresher` to automatically refresh GitLab access tokens before they expire. - The `TokenDataSource` now includes a `refreshIfNeeded` method, which is called before making authenticated API requests to GitLab. - Added `GITLAB_CLIENT_SECRET` to the build configuration to support the token refresh flow. - The authentication dialog now provides clearer messages for expired tokens, prompting the user to sign in again. **GitLab API Integration:** - Refactored `DetailsRepository` to use platform-specific (GitHub/GitLab) implementations for fetching repository details, releases, READMEs, and user profiles. - Correctly implemented API calls to fetch repository details by ID, latest releases, README files, and user profiles from the GitLab API. - Improved the mapping from `GitLabProjectNetworkModel` to the internal `GithubRepoSummary` model, ensuring consistent data handling across platforms. - Fixed an issue where the wrong token data source was used for authenticated GitLab HTTP clients. - Navigation now passes the current API platform to the details screen to ensure the correct repository data is fetched. **Minor Fixes & Refinements:** - The repository ID type has been changed from `Int` to `Long` to support GitLab's larger ID values. - Updated the authentication screen to display the GitLab icon when logging into GitLab. - Refactored Koin dependency injection modules for better organization, moving token-related dependencies into a new `tokenModule`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit introduces the foundational support for GitLab as an alternative API source alongside GitHub. It refactors the authentication, data fetching, and state management systems to be platform-agnostic.
Key Changes:
Multi-Platform Authentication:
ApiPlatformenum.GitLabAuthApito handle GitLab's OAuth 2.0 device authorization grant flow.TokenDataSourceandTokenStoreare updated to manage tokens separately for each platform.Platform-Aware Data Fetching:
HomeRepository,SearchRepository,DetailsRepository) and DI modules (Koin) are refactored to be platform-specific.GitLabProjectNetworkModel) for interacting with the GitLab API.toGithubRepoNetworkModel) to transform GitLab project data into a commonGithubRepoNetworkModelformat, allowing for consistent UI rendering.State Management & UI:
AppStateManagerandMainViewModelnow track authentication status, rate limits, and the currently selectedApiPlatformseparately.Code Refactoring & Housekeeping:
named("github"),named("gitlab")).Downloader,Installer,PackageMonitor) from feature packages to a centralcore/data/servicespackage for better project structure.