Repository navigation
feat: Remote Instance Catalog Fetch - #514
volodymyr-chekyrta merged 5 commits into
Conversation
Introduces Instance and InstancesConfig: what one Open edX platform is and how it is parsed from the INSTANCES block of the bundled config. Nothing reads it yet. Required fields are NAME, API_HOST_URL and OAUTH_CLIENT_ID; a malformed entry is dropped. KEY falls back to a slug of NAME, INSTANCE_NAME is localized with an English fallback, and PLATFORM_NAME defaults to the display name. The schema matches iOS (#672).
InstanceStore holds the instance catalog and the selected instance, persists the selection by key and publishes it as a StateFlow. A single-instance catalog selects its only instance automatically. Registered in Koin as InstanceStore and InstanceProvider; nothing consumes it yet. Mirrors iOS #673.
InstanceTheme derives a palette from an instance's accent color and its optional THEME.LIGHT/THEME.DARK overrides: only the fields an instance sets change, the rest keep the compiled default, and a missing dark value falls back to the light one. Palette field names are the ones iOS uses (#675), mapped onto AppColors. OpenEdXTheme observes InstanceThemeManager, which holds the selected instance's theme. Nothing applies a theme yet, so every screen still renders the default palette.
InstanceConfigLoader resolves the catalog the app runs with: the last cached remote catalog, else the bundled INSTANCES list, else nothing. A live fetch with at least one instance replaces that baseline and becomes the cache; a failed, malformed or empty response leaves it untouched. The catalog is fetched from INSTANCES_CATALOG_URL with a plain OkHttp client: no app interceptors, no credentials, a 10 second timeout. Remote snake_case keys are normalized with the same map iOS uses (#676). Nothing calls the loader at launch yet. Unlike iOS, the YAML build configuration stays: the Gradle build already turns it into the bundled config.json the loader reads.
|
Thanks for the pull request, @IvanStepanok! This repository is currently maintained by Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review. 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. DetailsWhere can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources: When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
|
@RawanMatar89 I merged |
Description
Adds fetching the instance catalog from a remote URL, with the bundled catalog as the offline fallback. Port of openedx-app-ios#676.
This PR only adds the fetch, cache and parse machinery. Nothing calls
InstanceConfigLoaderat launch yet; until the launch-sequencing PR the app boots on its bundled config as before.What's in this PR
Remote fetch, with an offline-safe merge policy
OkHttpInstanceApiService: a plain GET ofINSTANCES_CATALOG_URLwith an OkHttp client of its own, not the app's API client: no interceptors, no credentials, no HTTP cache, 10 second timeout. It is a fixed, anonymous endpoint.InstanceConfigLoader.load(): the baseline is the last cached successful fetch, else the bundled catalog, else empty.INSTANCES_CATALOG_URLis a new app-level key (empty in dev, stage and prod: bundled catalog only).Remote schema
instances/INSTANCES.snake_casekeys are renamed at every nesting depth with the same map iOS uses; unmapped keys pass through unchanged. Palette field names are never renamed.Not ported: YAML retirement
config.yamlwithconfig.json. Here the Gradle build already turnsconfig.yamlinto the bundledconfig.jsonthe loader reads, so instances are written in YAML and arrive in the same JSON shape iOS ships. Changing the build-config format would be a separate decision for this repo.Tests
InstanceConfigLoaderTest(17 cases) on a shared remote fixture: key normalization at every depth, untouched palette names, pass-through of unmapped keys, both payload shapes, rejected shapes, required fields; loader replace/cache/fallback semantics, including empty, malformed, offline and unparseable-cache cases and no request when no URL is set; the catalog request carries noAuthorizationorCookieheader and bypasses caches; non-2xx responses fail; the client has no interceptors and a 10 second timeout.Out of scope
Testing
./gradlew detektAll testProdDebugUnitTest :app:assembleProdDebug