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

ALTAPPS-557: StepQuizHints integrate State to ViewState mapping #330

Merged

Conversation

ivan-magda
Copy link
Member

@ivan-magda ivan-magda commented Jan 25, 2023

YouTrack Issues:
#ALTAPPS-557

Checklist

Before Code Review:

  • Fields "Assignees, Labels, Milestone" are filled in the pull request;
  • Sentry Performance Monitoring of screen loading is added for new screens;
  • View analytics events are added for new screens;
  • New analytics events are documented;
  • All checks have been passed;
  • Changes have been checked locally.

Description
For iOS, there are no differences in what to use Feature.State or Feature.ViewState -> we are just working with some state. The primary pain for iOS (like before with Feature.State) is when we are frequently using a sealed interface. We need to add Equatable conformance to those states to have the ability to notify View about data changes only when they really occurred (see for example StepQuizHintsViewStateKsExtensions.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.

@ivan-magda ivan-magda added this to the 1.8 milestone Jan 25, 2023
@ivan-magda ivan-magda self-assigned this Jan 25, 2023
@github-actions github-actions bot added android Android module task ios iOS module task shared Shared module task labels Jan 25, 2023
@ivan-magda ivan-magda marked this pull request as ready for review January 26, 2023 03:17
@ivan-magda ivan-magda added the awaiting review Pull Request is awaiting code reviews label Jan 26, 2023
Comment on lines 8 to +17
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 }
}
Copy link
Contributor

@XanderZhu XanderZhu Jan 26, 2023

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.

Copy link
Contributor

@XanderZhu XanderZhu Jan 26, 2023

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.

Copy link
Member Author

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.

@XanderZhu XanderZhu added awaiting changes Changes requested, waiting on author to update and removed awaiting review Pull Request is awaiting code reviews labels Jan 26, 2023
@ivan-magda ivan-magda added awaiting review Pull Request is awaiting code reviews and removed awaiting changes Changes requested, waiting on author to update labels Jan 31, 2023
@XanderZhu XanderZhu added ready to pull Pull Request is ready to merge and removed awaiting review Pull Request is awaiting code reviews labels Feb 1, 2023
@ivan-magda ivan-magda merged commit 160077a into develop Feb 2, 2023
@ivan-magda ivan-magda deleted the feature/ALTAPPS_557/integrate_state_to_viewstate_mapping branch February 2, 2023 06:50
@ivan-magda ivan-magda removed the ready to pull Pull Request is ready to merge label Feb 10, 2023
@ivan-magda ivan-magda mentioned this pull request Feb 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android Android module task ios iOS module task shared Shared module task
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants