-
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
Deep link to add secondary login in OldDot #6319
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -284,6 +284,37 @@ function subscribeToUserEvents() { | |
}); | ||
} | ||
|
||
/** | ||
* Subscribes to Expensify Card updates when checking loginList for private domains | ||
*/ | ||
function subscribeToExpensifyCardUpdates() { | ||
if (!currentUserAccountID) { | ||
return; | ||
} | ||
|
||
const pusherChannelName = `private-user-accountID-${currentUserAccountID}`; | ||
|
||
// Handle Expensify Card approval flow updates | ||
Pusher.subscribe(pusherChannelName, Pusher.TYPE.EXPENSIFY_CARD_UPDATE, (pushJSON) => { | ||
if (pushJSON.isUsingExpensifyCard) { | ||
Onyx.merge(ONYXKEYS.USER, {isUsingExpensifyCard: pushJSON.isUsingExpensifyCard, isCheckingDomain: null}); | ||
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. Why do we set 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. Setting it to |
||
Pusher.unsubscribe(pusherChannelName, Pusher.TYPE.EXPENSIFY_CARD_UPDATE); | ||
} else { | ||
Onyx.merge(ONYXKEYS.USER, {isCheckingDomain: pushJSON.isCheckingDomain}); | ||
} | ||
}, false, | ||
() => { | ||
NetworkConnection.triggerReconnectionCallbacks('pusher re-subscribed to private user channel'); | ||
}) | ||
.catch((error) => { | ||
Log.info( | ||
'[User] Failed to subscribe to Pusher channel', | ||
false, | ||
{error, pusherChannelName, eventName: Pusher.TYPE.EXPENSIFY_CARD_UPDATE}, | ||
); | ||
}); | ||
} | ||
|
||
/** | ||
* Sync preferredSkinTone with Onyx and Server | ||
* @param {String} skinTone | ||
|
@@ -318,4 +349,5 @@ export { | |
setPreferredSkinTone, | ||
setShouldUseSecureStaging, | ||
clearUserErrorMessage, | ||
subscribeToExpensifyCardUpdates, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,70 @@ | ||
import React from 'react'; | ||
import {View} from 'react-native'; | ||
import {withOnyx} from 'react-native-onyx'; | ||
import Text from '../../../components/Text'; | ||
import styles from '../../../styles/styles'; | ||
import withLocalize, {withLocalizePropTypes} from '../../../components/withLocalize'; | ||
import {Concierge} from '../../../components/Icon/Expensicons'; | ||
import {Mail} from '../../../components/Icon/Expensicons'; | ||
import {JewelBoxBlue} from '../../../components/Icon/Illustrations'; | ||
import UnorderedList from '../../../components/UnorderedList'; | ||
import WorkspaceSection from '../WorkspaceSection'; | ||
import {navigateToConciergeChat} from '../../../libs/actions/Report'; | ||
import Navigation from '../../../libs/Navigation/Navigation'; | ||
import {openOldDotLink} from '../../../libs/actions/Link'; | ||
import {subscribeToExpensifyCardUpdates} from '../../../libs/actions/User'; | ||
import ONYXKEYS from '../../../ONYXKEYS'; | ||
import compose from '../../../libs/compose'; | ||
|
||
const propTypes = { | ||
...withLocalizePropTypes, | ||
}; | ||
|
||
const WorkspaceCardVBANoECardView = props => ( | ||
<WorkspaceSection | ||
title={props.translate('workspace.card.header')} | ||
icon={JewelBoxBlue} | ||
menuItems={[ | ||
{ | ||
title: props.translate('workspace.card.chatWithConcierge'), | ||
onPress: () => { | ||
Navigation.dismissModal(); | ||
navigateToConciergeChat(); | ||
<> | ||
<WorkspaceSection | ||
title={props.translate('workspace.card.header')} | ||
icon={JewelBoxBlue} | ||
menuItems={[ | ||
{ | ||
title: props.translate('workspace.card.addWorkEmail'), | ||
onPress: () => { | ||
Navigation.dismissModal(); | ||
openOldDotLink('settings?param={"section":"account","openModal":"secondaryLogin"}'); | ||
subscribeToExpensifyCardUpdates(); | ||
}, | ||
icon: Mail, | ||
shouldShowRightIcon: true, | ||
}, | ||
icon: Concierge, | ||
shouldShowRightIcon: true, | ||
}, | ||
]} | ||
> | ||
<View style={[styles.mv4]}> | ||
<Text>{props.translate('workspace.card.VBANoECardCopy')}</Text> | ||
</View> | ||
|
||
<UnorderedList | ||
items={[ | ||
props.translate('workspace.card.benefit1'), | ||
props.translate('workspace.card.benefit2'), | ||
props.translate('workspace.card.benefit3'), | ||
props.translate('workspace.card.benefit4'), | ||
]} | ||
/> | ||
> | ||
<View style={[styles.mv4]}> | ||
<Text>{props.translate('workspace.card.VBANoECardCopy')}</Text> | ||
</View> | ||
|
||
<View style={[styles.mv4]}> | ||
<Text>{props.translate('workspace.card.conciergeCanHelp')}</Text> | ||
</View> | ||
</WorkspaceSection> | ||
<UnorderedList | ||
items={[ | ||
props.translate('workspace.card.benefit1'), | ||
props.translate('workspace.card.benefit2'), | ||
props.translate('workspace.card.benefit3'), | ||
props.translate('workspace.card.benefit4'), | ||
]} | ||
/> | ||
</WorkspaceSection> | ||
{props.user.isCheckingDomain && ( | ||
<Text style={[styles.m5, styles.formError]}> | ||
{props.translate('workspace.card.checkingDomain')} | ||
</Text> | ||
)} | ||
</> | ||
); | ||
|
||
WorkspaceCardVBANoECardView.propTypes = propTypes; | ||
WorkspaceCardVBANoECardView.displayName = 'WorkspaceCardVBANoECardView'; | ||
|
||
export default withLocalize(WorkspaceCardVBANoECardView); | ||
export default compose( | ||
withLocalize, | ||
withOnyx({ | ||
user: { | ||
key: ONYXKEYS.USER, | ||
}, | ||
}), | ||
)(WorkspaceCardVBANoECardView); |
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.
It looks like we use the same in
subscribeToUserEvents
, can we consolidate those somehow? Also, is there a reason we don't need to check ifcurrentUserAccountID
exists in this function?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 is a one-time only subscription that happens when the user clicks the
Add work email address
link. Adding it tosubscribeToUserEvents
would subscribe users prematurely and unnecessarily.I didn't add the check because when the user subscribes to this event we should have a
currentUserAccountID
. That is different fromsubscribeToUserEvents
becausesubscribeToUserEvents
is called upon login and race conditions could causecurrentUserAccountID
to be undefined. With that being said, I'll add the check just to be safe.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.
Sounds good, thanks for the explanation!