-
-
Notifications
You must be signed in to change notification settings - Fork 45
Complete profile refactor #3139
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
Conversation
…tabase on success, refactored the api call as common standard
|
@coderabbitai full review please |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chainI'll help you with a full review of PR #3139. Let me gather the necessary information about the pull request first. 🏁 Script executed: Length of output: 14148 Now let me examine the specific files and conduct a deeper analysis of the codebase to understand the full context and potential impacts. 🏁 Script executed: Length of output: 7594 🏁 Script executed: Length of output: 21237 @pm-dimagi I'll provide a comprehensive review of this profile refactor PR. Let me examine the changes and identify potential issues. 🔍 Code Review SummaryThis is a significant architectural refactor that moves from a database-first to session-first approach for profile completion, with improved authentication patterns. Here are my findings:
|
|
reviewers Here the file CompleteProfileParser and BackupCodeParser is almost same i still kept it different for code clearnce and if there is any change in the future in fields |
| private ConnectUserRecord connectUserRecord; | ||
| private PersonalIdSessionData personalIdSessionData; | ||
| private String photoAsBase64; | ||
| private PersonalIdSessionDataViewModel personalIdSessionDataViewModel; |
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.
Nit: Can be a local variable
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.
| public void processTokenRequestDeniedError() { | ||
| break; | ||
| case TOKEN_UNAVAILABLE_ERROR: | ||
| onPhotoUploadFailure(requireContext().getString(R.string.recovery_network_token_unavailable), |
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.
This should go to ConnectNetworkHelper.handleTokenDeniedException, which will crash the app, then delete the DB and tell the user to configure PersonalID again when they restart the app.
app/src/org/commcare/fragments/personalId/PersonalIdPhotoCaptureFragment.java
Show resolved
Hide resolved
| sessionData.setPersonalId(JsonExtensions.optStringSafe(json, "username", null)); | ||
| sessionData.setDbKey(JsonExtensions.optStringSafe(json, "db_key", null)); | ||
| sessionData.setOauthPassword(JsonExtensions.optStringSafe(json, "password", null)); |
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.
these keys must be mandatory now right ?
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.
yes it is
d33374e
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.
think using optStringSafe is fine there but we should do a separate invalidation later on each of these paramertes to be non null and throw a different exception than Json Exception, maybe IllegalStateException . This is because we still want to check for "null" strings when validating this, the handling for which is only built in optStringSafe and not getString
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.
app/src/org/commcare/fragments/personalId/PersonalIdPhotoCaptureFragment.java
Show resolved
Hide resolved
| private void savePhotoToDatabase(String photoAsBase64) { | ||
| connectUserRecord.setPhoto(photoAsBase64); | ||
| ConnectUserDatabaseUtil.storeUser(requireContext(), connectUserRecord); | ||
| private void saveDataToDatabase(String photoAsBase64) { |
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.
nit: call it createAndSaveConnectUser
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.
…ndroid into pm_ccct_1223_3 # Conflicts: # app/src/org/commcare/fragments/personalId/PersonalIdBackupCodeFragment.java
| if (personalIdSessionData.getDbKey() == null || personalIdSessionData.getOauthPassword() == null || | ||
| personalIdSessionData.getPersonalId() == null) { | ||
| throw new IllegalArgumentException("Mandatory fields are null"); | ||
| } |
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.
can we use Objects.requireNonNull( inside response parser instead after we have parsed these.
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.
Product Description
Refactored the complete profile page on the following
Technical Summary
Feature Flag
Safety Assurance
Safety story
Automated test coverage
QA Plan
Labels and Review