Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Handle JSON enums with unknown values #462

Merged
merged 2 commits into from
Feb 21, 2024

Conversation

nikclayton
Copy link
Contributor

Previous code expected all incoming enums values to map directly to Kotlin enum constants.

This is a problem for servers with additional features -- e.g., "reaction" as a notification type.

Fix this with a new Moshi adapter that will set the incoming value to a given constant if it's not recognised.

Apply this to the enum constants in core.network to ensure they are handled.

Clean up enum handling in Converters.kt, ComposeViewModel.kt, and Status.kt by using the existing .ordinal property and some extension functions for idiomatic code.

Fixes #461

Previous code expected all incoming enums values to map directly to
Kotlin enum constants.

This is a problem for servers with additional features -- e.g.,
"reaction" as a notification type.

Fix this with a new Moshi adapter that will set the incoming value
to a given constant if it's not recognised.

Apply this to the enum constants in core.network to ensure they are
handled.

Clean up enum handling in Converters.kt, ComposeViewModel.kt, and
Status.kt by using the existing `.ordinal` property and some
extension functions for idiomatic code.

Fixes pachli#461
@nikclayton nikclayton merged commit 2162e03 into pachli:main Feb 21, 2024
6 checks passed
@nikclayton nikclayton deleted the 461-unknown-enum-values branch February 21, 2024 22:36
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.

error when someone reacts to a post, breaking notification tab
1 participant