-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
[Money2020] Adding in activation flow for money20/20 #29288
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
833cc72
Adding in activation flow for money2020
Beamanator 4d7e665
Add in needed imports
Beamanator 1841896
Fix up demo action
Beamanator d96a807
Fix existing report route logic
Beamanator 55119bd
Fix double-triggering demo flow
Beamanator aaab625
Address lint issues
Beamanator c343630
I guess this belongs here
Beamanator bb922d8
prettier didn't like... something
Beamanator 0a3ce76
Merge branch 'main' of github.com:Expensify/App into beaman-activatio…
Beamanator 1681974
Add money2020 deep link
Beamanator 7044381
Remove old code
Beamanator 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 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 |
---|---|---|
|
@@ -79,6 +79,10 @@ | |
{ | ||
"/": "/search/*", | ||
"comment": "Search" | ||
}, | ||
{ | ||
"/": "/money2020/*", | ||
"comment": "Money 2020" | ||
} | ||
] | ||
} | ||
|
This file contains 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 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 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 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 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 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 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,70 @@ | ||
import Config from 'react-native-config'; | ||
import Onyx from 'react-native-onyx'; | ||
import lodashGet from 'lodash/get'; | ||
import * as API from '../API'; | ||
import * as ReportUtils from '../ReportUtils'; | ||
import Navigation from '../Navigation/Navigation'; | ||
import ROUTES from '../../ROUTES'; | ||
import ONYXKEYS from '../../ONYXKEYS'; | ||
|
||
let currentUserEmail; | ||
Onyx.connect({ | ||
key: ONYXKEYS.SESSION, | ||
callback: (val) => { | ||
currentUserEmail = lodashGet(val, 'email', ''); | ||
}, | ||
}); | ||
|
||
function runMoney2020Demo() { | ||
// Try to navigate to existing demo chat if it exists in Onyx | ||
const money2020AccountID = Number(Config ? Config.EXPENSIFY_ACCOUNT_ID_MONEY2020 : 15864555); | ||
const existingChatReport = ReportUtils.getChatByParticipants([money2020AccountID]); | ||
if (existingChatReport) { | ||
// We must call goBack() to remove the demo route from nav history | ||
Navigation.goBack(); | ||
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(existingChatReport.reportID)); | ||
return; | ||
} | ||
|
||
// We use makeRequestWithSideEffects here because we need to get the chat report ID to navigate to it after it's created | ||
// eslint-disable-next-line rulesdir/no-api-side-effects-method | ||
API.makeRequestWithSideEffects('CreateChatReport', { | ||
emailList: `${currentUserEmail},money2020@expensify.com`, | ||
activationConference: 'money2020', | ||
}).then((response) => { | ||
// If there's no response or no reportID in the response, navigate the user home so user doesn't get stuck. | ||
if (!response || !response.reportID) { | ||
Navigation.goBack(); | ||
Navigation.navigate(ROUTES.HOME); | ||
return; | ||
} | ||
|
||
// Get reportID & navigate to it | ||
// Note: We must call goBack() to remove the demo route from history | ||
const chatReportID = response.reportID; | ||
Navigation.goBack(); | ||
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(chatReportID)); | ||
}); | ||
} | ||
|
||
/** | ||
* Runs code for specific demos, based on the provided URL | ||
* | ||
* @param {String} url - URL user is navigating to via deep link (or regular link in web) | ||
*/ | ||
function runDemoByURL(url = '') { | ||
const cleanUrl = (url || '').toLowerCase(); | ||
|
||
if (cleanUrl.endsWith(ROUTES.MONEY2020)) { | ||
Onyx.set(ONYXKEYS.DEMO_INFO, { | ||
money2020: { | ||
isBeginningDemo: true, | ||
}, | ||
}); | ||
} else { | ||
// No demo is being run, so clear out demo info | ||
Onyx.set(ONYXKEYS.DEMO_INFO, null); | ||
} | ||
} | ||
|
||
export {runMoney2020Demo, runDemoByURL}; |
This file contains 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 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
Oops, something went wrong.
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.
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.
NAB. But is there any specific reason why we are no longer using the navigation promise?
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.
I looked around at other similar implementations and noticed we don't use it anymore - and we were somehow getting inside this call twice which called
CreateChatReport
twice, but without that function we only get there once 🤷