Repository navigation
feat: add instance selection store (InstanceStore) - #512
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.
|
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. |
Summary
Adds
InstanceStore: the single source of truth for the instance catalog and the selected instance. Port of openedx-app-ios#673. Still foundation: nothing in the app reads it yet.Included
InstanceProvider: read-only access to the selected instance, plus aStateFlowof it (the Android counterpart of iOS's.instanceDidChangenotification).InstanceStore: holds the catalog in effect and the selection, persisted by key in its ownSharedPreferencesfile and written synchronously, so a switch right before a process kill isn't lost. A single-instance catalog selects its only instance automatically, including after a deselect. A saved key the catalog no longer contains resolves to nothing but stays saved, so the site is selected again if a later catalog brings it back.Config.getInstancesConfig()exposes the bundled catalog; Koin registersInstanceStoreandInstanceProvider.InstanceStoreTest: 10 cases.Not included
Testing
./gradlew detektAll testProdDebugUnitTest :app:assembleProdDebugNote
This is the 2nd pull request of the multi-instance stack.