Skip to content

Conversation

@rainxchzed
Copy link
Owner

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.

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`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants