-
Notifications
You must be signed in to change notification settings - Fork 11
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
ALTAPPS-557: StepQuizHints integrate State to ViewState mapping #330
ALTAPPS-557: StepQuizHints integrate State to ViewState mapping #330
Conversation
...rc/commonMain/kotlin/org/hyperskill/app/step_quiz_hints/presentation/StepQuizHintsFeature.kt
Outdated
Show resolved
Hide resolved
...Main/kotlin/org/hyperskill/app/step_quiz_hints/presentation/StepQuizHintsActionDispatcher.kt
Outdated
Show resolved
Hide resolved
...rc/commonMain/kotlin/org/hyperskill/app/step_quiz_hints/view/model/StepQuizHintsViewState.kt
Outdated
Show resolved
Hide resolved
SEEN(JsonPrimitive("seen")), | ||
HELPFUL(JsonPrimitive("helpful")), | ||
UNHELPFUL(JsonPrimitive("unhelpful")), | ||
UNHELPFUL(JsonPrimitive("unhelpful")); | ||
|
||
companion object { | ||
private val VALUES: Array<HintState> = values() | ||
|
||
fun getByStringValue(value: String): HintState? = | ||
VALUES.firstOrNull { it.userStorageValue.jsonPrimitive.content == value } | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
enums can be automatically serialized using kotlinx.serialization
. You don't need to use JsonProomotive
.
In this case you just need to mark each invariant with @SerialName("originName")
annotation.
See documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, enumentry it's own built-in name and can be created via
.valueOf()` method.
See documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main usage of the HintState
is in StepQuizHintsActionDispatcher
when updating user storage via UserStorageInteractor
. The UserStorageInteractor
API works with the JSON types directly (see /user_storage/domain/model/UserStorage.kt
). So it's currently impossible to implement the proposed changes and it's out of the scope of this PR.
YouTrack Issues:
#ALTAPPS-557
Checklist
Before Code Review:
Description
For iOS, there are no differences in what to use
Feature.State
orFeature.ViewState
-> we are just working with some state. The primary pain for iOS (like before withFeature.State
) is when we are frequently using asealed interface
. We need to addEquatable
conformance to those states to have the ability to notify View about data changes only when they really occurred (see for exampleStepQuizHintsViewStateKsExtensions.swift
). Hope in the future we will move this into shared logic.In general, I like that kind of ViewState. We are not exposing Feature.State to the platform code, but only required ViewState for displaying the UI on the platforms.
Also, see my comments in the code.