-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Refactor UpdateAccount in App #9764
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
10aeb96
rm Report_TogglePinned from deprecatedAPI
luacmartins 3c38d5c
add logic to setExpensifyNewsStatus
luacmartins d2cb0c5
rename setExpensifyNewsStatus to updateNewsletterSubscriptionStatus
luacmartins 675fc45
rm UpdateAccount from deprecatedAPI
luacmartins fdd5597
rename API command
luacmartins e5eadb6
create onyx migration
luacmartins File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -330,19 +330,6 @@ function Report_GetHistory(parameters) { | |
| return Network.post(commandName, parameters); | ||
| } | ||
|
|
||
| /** | ||
| * @param {Object} parameters | ||
| * @param {Number} parameters.reportID | ||
| * @param {Boolean} parameters.pinnedValue | ||
| * @returns {Promise} | ||
| */ | ||
| function Report_TogglePinned(parameters) { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I noticed that we refactored this command but didn't remove it from deprecatedAPI. So I'm removing it here |
||
| const commandName = 'Report_TogglePinned'; | ||
| requireParameters(['reportID', 'pinnedValue'], | ||
| parameters, commandName); | ||
| return Network.post(commandName, parameters); | ||
| } | ||
|
|
||
| /** | ||
| * @param {Object} parameters | ||
| * @param {Number} parameters.reportID | ||
|
|
@@ -428,17 +415,6 @@ function SetWalletLinkedAccount(parameters) { | |
| return Network.post(commandName, parameters); | ||
| } | ||
|
|
||
| /** | ||
| * @param {Object} parameters | ||
| * @param {String} parameters.subscribed | ||
| * @returns {Promise} | ||
| */ | ||
| function UpdateAccount(parameters) { | ||
| const commandName = 'UpdateAccount'; | ||
| requireParameters(['subscribed'], parameters, commandName); | ||
| return Network.post(commandName, parameters); | ||
| } | ||
|
|
||
| /** | ||
| * @param {Object} parameters | ||
| * @param {String} parameters.message | ||
|
|
@@ -940,15 +916,13 @@ export { | |
| RejectTransaction, | ||
| Report_AddComment, | ||
| Report_GetHistory, | ||
| Report_TogglePinned, | ||
| Report_EditComment, | ||
| Report_UpdateLastRead, | ||
| ResendValidateCode, | ||
| ResetPassword, | ||
| SetNameValuePair, | ||
| SetPassword, | ||
| SetWalletLinkedAccount, | ||
| UpdateAccount, | ||
| UpdatePolicy, | ||
| User_SignUp, | ||
| User_Delete, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import Onyx from 'react-native-onyx'; | ||
| import _ from 'underscore'; | ||
| import ONYXKEYS from '../../ONYXKEYS'; | ||
| import Log from '../Log'; | ||
|
|
||
| // This migration changes the name of the Onyx key user.expensifyNewsStatus from expensifyNewsStatus to isSubscribedToNewsletter | ||
| export default function () { | ||
| return new Promise((resolve) => { | ||
| // Connect to the USER key in Onyx to get the value of expensifyNewsStatus | ||
| // then set that value as isSubscribedToNewsletter | ||
| // finally remove expensifyNewsStatus by setting the value to null | ||
| const connectionID = Onyx.connect({ | ||
| key: ONYXKEYS.USER, | ||
| callback: (user) => { | ||
| Onyx.disconnect(connectionID); | ||
|
|
||
| // Fail early here because there is nothing to migrate | ||
| if (!user || _.isNull(user.expensifyNewsStatus) || _.isUndefined(user.expensifyNewsStatus)) { | ||
| Log.info('[Migrate Onyx] Skipped migration RenameExpensifyNewsStatus'); | ||
| return resolve(); | ||
| } | ||
|
|
||
| // eslint-disable-next-line rulesdir/prefer-actions-set-data | ||
| Onyx.merge(ONYXKEYS.USER, { | ||
| expensifyNewsStatus: null, | ||
| isSubscribedToNewsletter: user.expensifyNewsStatus, | ||
| }) | ||
| .then(() => { | ||
| Log.info('[Migrate Onyx] Ran migration RenameExpensifyNewsStatus'); | ||
| resolve(); | ||
| }); | ||
| }, | ||
| }); | ||
| }); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.