Skip to content

Conversation

@david-venhoff
Copy link
Member

@david-venhoff david-venhoff commented Oct 11, 2025

Short Description

Draft to switch to the v2 api of the cms. Should not be merged before api v2 is available in the production cms.

This pr will hold all the changes to the api endpoints and will only be ready to merge when every endpoint is migrated.

Proposed Changes

  • Add localhost cms server url to simplify implementation & testing
  • Update the urls to use v2

Side Effects

Testing

Resolved Issues

Fixes: #1141


@david-venhoff david-venhoff force-pushed the use-api-v2 branch 8 times, most recently from ba24658 to 4082446 Compare October 15, 2025 13:41
@LeandraH
Copy link
Contributor

When running this branch on a fresh simulator (e.g. because I finally updated Xcode 😅 ), you can't really open the app; you keep getting a 404 popup on Android where you can only hit "Try again", and on iOS, the build pauses in Xcode and you can't continue. We can fix this sometime in the future, it's more of a note to myself in the future: Switch to main, choose a profession, you can switch back to this branch then.

@david-venhoff
Copy link
Member Author

Still to do:

  • Wait for the production CMS to migrate all old jobs
  • Add release note
  • Do some testing and decide on whether it is feasible to keep user progress
  • Otherwise, add note about potentially lost progress

To make it possible to test with a local cms server
This will prevent an old `cmsOverwrite` value from being kept
after updating the app
This commit leaves most of the implementation in tact, so that we can reuse parts of it should we decide to re-add this feature.
However, users will not be able to interact with it anymore
* Add `CmsApi` service and switch the words endpoint

* Dont store `id` field of images

The new API does not deliver an `id` field and it was also not used in the code at all.

* Mark types in `migrate1To2` as incomplete to signify intent
* Rename professions to jobs to match the new cms terminology

* Remove the distinction between `ScopeSelection` and `JobSelection`

The new api has no concept of job categories anymore, so instead we will want to list all jobs on the same screen in the future

- Remove `JobSelection`
- Rename the old `ScopeSelectionScreen` to `JobSelection`

* labels: rename `manageSelection` to `manageJobs`

* use new api in JobSelection

TODO: combine `JobSelection` and `FilteredJobList`

- Add new CmsApi service for all api calls
- Add hook to load all jobs
- Update `JobSelection` to use the new hook and get rid of the root level disciplines

* use new api in JobCard

* use new api in SelectionItem
The api v2 now returnes an array of images, instead of a single image
- Add new api endpoint in `CmsApi.ts`
- Move the model to `models/sponsor.ts`
* Rename DisciplineSelectionScreen to UnitSelectionScreen, to match the new naming convention

* Add endpoints for units of jobs and words of units

Also updates the model of units, which lead to some further changes:
- Rename more instances of `Discipline` to either `Job` or `Unit`
- Create Unit model in new directory model/unit.ts
    - Differentiate between standard units and user vocabulary units in the type system, so that the ids cannot be mixed up anymore accidentally
    - This uncovered some bugs where ids of standard units and user vocabulary units got mixed up!
    - For example, in user vocabulary exercises, progress is ignored. However, it still got updated and would have changed standard units with the same id.
- Migrate hooks still using the old api
- Add hook to load units
- Make `useReadProgress` async, because the api no longer sends out units of jobs

* Rename `title` to `jobTitle` in `NextExerciseData` for clarification

* Migrate `useLoadVocabularyItems`

* Simplify ExercisesParams

This gets rid of a few unused parameters and makes the code easier to read

* Remove some hooks that are now unused

* Fix type of `VocabularyItemType`

technically not relevant for this pr, but its a small fix

* Fix duplicateKeyWarning in `FavoritesScreen`

Not 100% sure what the exact problem was, might be caused by `FavoriteItem` not assigning a key if the data haven't loaded yet.
Instead, I just use a keyExtractor on the list
* Migrate feedback to new api

- Add endpoint to `CmsAPI.ts`
- Add feedback model
- Fix bug where it was possible to create feedback about user vocabulary & units
* Remove filtered job search list

Now that there are no more groups of professions, there is no
reason to not use the normal job list when searching.
This also improves the UI.

Also remove the now unused function to split text
- Remove global state
- Rely less on mutation
* Add `Job` type and remove `Discipline`

* Remove leftover occurrences of `Discipline`

Exceptions:
- Left `CustomDisciplines` since there is no new name for them yet
- Left `DisciplineListItem` since I could not think of a better name and did not want to split the file
* Move `VocabularyItem` to the model directory

* Refactor id of `VocabularyItem`

Instead of storing `id`, `type` and `apiKey` in the object, we will now move these fields into a new type `VocabularyItemId`.

The advantage is that we now have a type-safe way of working with `VocabularyItem`s without confusion about where it came from.

- No feedback about protected vocabulary
- no wrong type in api
- no more wrong keys in list items
- easier conversion from vocabulary items to favorites
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.

Meta: Migrate to new cms api model

3 participants